Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
Validate has identity exists and try to use it before attempting to p…
Browse files Browse the repository at this point in the history
…ull the roles
  • Loading branch information
Will Hattingh committed Oct 8, 2013
1 parent 852cbe6 commit 3b99ff2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ZfcRbac/Collector/RbacCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ public function collect(MvcEvent $mvcEvent)
$this->collectedOptions = $rbacConfig;
$identityProvider = $sm->get($rbacConfig['identity_provider']);
$rbacService = $sm->get('ZfcRbac\Service\Rbac');
if (method_exists($identityProvider, 'getIdentity')) {
$identity = $identityProvider->getIdentity();
$this->collectedRoles = $identity->getRoles();
if (method_exists($identityProvider, 'getIdentity') && method_exists($identityProvider, 'hasIdentity')) {
if ($identityProvider->hasIdentity()) {
$identity = $identityProvider->getIdentity();
$this->collectedRoles = $identity->getRoles();
}
} else {
$rbac = $rbacService->getRbac();
$roles = array();
Expand Down

0 comments on commit 3b99ff2

Please sign in to comment.