Skip to content

Commit

Permalink
[zendframework#3693] CS fixes
Browse files Browse the repository at this point in the history
- Docblock additions/edits
- Logic workflow
  • Loading branch information
weierophinney committed Mar 25, 2013
1 parent 046adc6 commit 5920073
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
24 changes: 12 additions & 12 deletions library/Zend/View/Helper/Navigation/AbstractHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,13 +814,11 @@ public function accept(AbstractPage $page, $recursive = true)
* Determines whether a page should be allowed given certain parameters
*
* @param array $params
*
* @return boolean
*/
protected function isAllowed($params)
{
$results = $this->getEventManager()->trigger(__FUNCTION__, $this, $params);

return $results->last();
}

Expand Down Expand Up @@ -917,17 +915,19 @@ public static function setDefaultRole($role = null)
}
}

/**
* Attaches default ACL listeners, if ACLs are in use
*/
protected function setDefaultListeners()
{
if ($this->getUseAcl()) {

$this->getEventManager()->getSharedManager()->attach(
'Zend\View\Helper\Navigation\AbstractHelper',
'isAllowed',
array('Zend\View\Helper\Navigation\Listener\AcListener', 'accept'),
-1
);
if (!$this->getUseAcl()) {
return;
}

$this->getEventManager()->getSharedManager()->attach(
'Zend\View\Helper\Navigation\AbstractHelper',
'isAllowed',
array('Zend\View\Helper\Navigation\Listener\AclListener', 'accept')
);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
/**
* Default Access Control Listener
*/
class AcListener
class AclListener
{

/**
* Determines whether a page should be accepted by ACL when iterating
*
Expand All @@ -34,26 +33,23 @@ class AcListener
public static function accept(Event $event)
{
$accepted = true;
$params = $event->getParams();
$acl = $params['acl'];
$page = $params['page'];
$role = $params['role'];

$params= $event->getParams();

$acl = $params['acl'];
$page = $params['page'];
$role = $params['role'];

if ($acl) {

$resource = $page->getResource();
$privilege = $page->getPrivilege();
if (!$acl) {
return $accepted;
}

$resource = $page->getResource();
$privilege = $page->getPrivilege();

if ($resource || $privilege) {
$accepted = $acl->hasResource($resource)
&& $acl->isAllowed($role, $resource, $privilege);
}

if ($resource || $privilege) {
$accepted = $acl->hasResource($resource) && $acl->isAllowed($role, $resource, $privilege);
} else {
$accepted = true;
}
}

return $accepted;
}

}
}

0 comments on commit 5920073

Please sign in to comment.