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

Commit

Permalink
Fix a collector issue with standard identity provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitecon committed Oct 7, 2013
2 parents 2061975 + df3a639 commit 852cbe6
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/ZfcRbac/Collector/RbacCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use Zend\Mvc\MvcEvent;
use ZendDeveloperTools\Collector\CollectorInterface;

class RbacCollector implements CollectorInterface, Serializable {
class RbacCollector implements CollectorInterface, Serializable
{
/**
* Collector priority
*/
Expand All @@ -17,10 +18,12 @@ class RbacCollector implements CollectorInterface, Serializable {
* @var array|null
*/
protected $collectedRoles = array();

/**
* @var array|null
*/
protected $collectedFirewalls = array();

/**
* @var array|null
*/
Expand All @@ -31,7 +34,8 @@ class RbacCollector implements CollectorInterface, Serializable {
*
* @return string
*/
public function getName() {
public function getName()
{
return 'zfcrbac';
}

Expand All @@ -40,7 +44,8 @@ public function getName() {
*
* @return integer
*/
public function getPriority() {
public function getPriority()
{
return self::PRIORITY;
}

Expand All @@ -49,7 +54,8 @@ public function getPriority() {
*
* @param MvcEvent $mvcEvent
*/
public function collect(MvcEvent $mvcEvent) {
public function collect(MvcEvent $mvcEvent)
{
if (!$application = $mvcEvent->getApplication()) {
return;
}
Expand All @@ -59,13 +65,13 @@ 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')) {
if (method_exists($identityProvider, 'getIdentity')) {
$identity = $identityProvider->getIdentity();
$this->collectedRoles = $identity->getRoles();
}else{
} else {
$rbac = $rbacService->getRbac();
$roles = array();
foreach ($rbac as $role){
foreach ($rbac as $role) {
$roles[] = $role->getName();
}
$this->collectedRoles = $roles;
Expand All @@ -77,16 +83,20 @@ public function collect(MvcEvent $mvcEvent) {
/**
* @return array|string[]
*/
public function getCollection() {
public function getCollection()
{
return $this->collection;
}

/**
* {@inheritDoc}
*/
public function serialize() {
return serialize(
array(
public function serialize()
{
return serialize
(
array
(
'roles' => $this->collectedRoles,
'firewalls' => $this->collectedFirewalls,
'options' => $this->collectedOptions
Expand All @@ -97,8 +107,8 @@ public function serialize() {
/**
* {@inheritDoc}
*/
public function unserialize($serialized) {
public function unserialize($serialized)
{
$this->collection = unserialize($serialized);
}

}

0 comments on commit 852cbe6

Please sign in to comment.