diff --git a/src/ZfcRbac/Identity/IdentityInterface.php b/src/ZfcRbac/Identity/IdentityInterface.php index 624a5f59..75b8faf7 100644 --- a/src/ZfcRbac/Identity/IdentityInterface.php +++ b/src/ZfcRbac/Identity/IdentityInterface.php @@ -29,7 +29,8 @@ interface IdentityInterface /** * Get the list of roles of this identity * + * @param string $context Optional context for determining roles returned, eg. project name as context * @return string[]|\Rbac\Role\RoleInterface[] */ - public function getRoles(); + public function getRoles($context = null); } diff --git a/src/ZfcRbac/Service/AuthorizationService.php b/src/ZfcRbac/Service/AuthorizationService.php index ebbf4c1e..f0a2e5d7 100644 --- a/src/ZfcRbac/Service/AuthorizationService.php +++ b/src/ZfcRbac/Service/AuthorizationService.php @@ -121,7 +121,7 @@ public function getIdentity() */ public function isGranted($permission, $context = null) { - $roles = $this->roleService->getIdentityRoles(); + $roles = $this->roleService->getIdentityRoles($context); if (empty($roles)) { return false; diff --git a/src/ZfcRbac/Service/RoleService.php b/src/ZfcRbac/Service/RoleService.php index 3fb131b3..51333c57 100644 --- a/src/ZfcRbac/Service/RoleService.php +++ b/src/ZfcRbac/Service/RoleService.php @@ -107,10 +107,11 @@ public function getIdentity() /** * Get the identity roles from the current identity, applying some more logic * + * @param string $context Optional context for determining roles returned, eg. project name as context * @return RoleInterface[] * @throws Exception\RuntimeException */ - public function getIdentityRoles() + public function getIdentityRoles($context = null) { if (!$identity = $this->getIdentity()) { return $this->convertRoles([$this->guestRole]); @@ -123,7 +124,7 @@ public function getIdentityRoles() )); } - return $this->convertRoles($identity->getRoles()); + return $this->convertRoles($identity->getRoles($context)); } /**