Skip to content

Instantly share code, notes, and snippets.

@Swader
Created September 12, 2012 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Swader/3705658 to your computer and use it in GitHub Desktop.
Save Swader/3705658 to your computer and use it in GitHub Desktop.
Fetching roles for a user
// Use case for StaffHandler -> fetching roles for a user
/* This is only valid if you're doing it
* in the IntechController - and ONLY if you have previously
* defined $this->oRegistry as
* $this->oRegistry = $this->getRegistry();
*/
$oStaffHandler = new StaffHandler($this->oRegistry->get('StaffMapper'));
$oEntity = new Entity(Entity::SELF, 0); // <-- looking for roles 'on himself' (HIS roles)
$oUser = new User($this->oRegistry->get('UserMapper'));
$oUser->setId($iAccountId);
$aRoles = $oStaffHandler->setEntity($oEntity)->setUser($oUser)->fetchRelationships();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment