本文整理汇总了PHP中Zend\Navigation\Page\AbstractPage::getResource方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPage::getResource方法的具体用法?PHP AbstractPage::getResource怎么用?PHP AbstractPage::getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Navigation\Page\AbstractPage
的用法示例。
在下文中一共展示了AbstractPage::getResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acceptAcl
/**
* Determines whether a page should be accepted by ACL when iterating
*
* Rules:
* - If helper has no ACL, page is accepted
* - If page has a resource or privilege defined, page is accepted
* if the ACL allows access to it using the helper's role
* - If page has no resource or privilege, page is accepted
*
* @param AbstractPage $page page to check
* @return bool whether page is accepted by ACL
*/
protected function acceptAcl(AbstractPage $page)
{
if (!($acl = $this->getAcl())) {
// no acl registered means don't use acl
return true;
}
$role = $this->getRole();
$roles = $this->getRoles();
$resource = $page->getResource();
if ($resource === NULL) {
return true;
}
$resource = $this->acl->hasResourceOrParent($resource);
if ($resource === false || $resource === NULL) {
return false;
}
if (!$roles) {
$roles = array($role);
}
if ($resource) {
foreach ($roles as $r) {
/**
* TODO: for now this has been set to allow an item if its resource is not found
*/
if (!$acl->hasResource($resource) || $acl->isAllowed($r, $resource)) {
return true;
}
}
return false;
}
return true;
}
示例2: acceptAcl
/**
* Determines whether a page should be accepted by ACL when iterating
*
* Rules:
* - If helper has no ACL, page is accepted
* - If page has a resource or privilege defined, page is accepted
* if the ACL allows access to it using the helper's role
* - If page has no resource or privilege, page is accepted
*
* @param AbstractPage $page page to check
* @return bool whether page is accepted by ACL
*/
protected function acceptAcl(AbstractPage $page)
{
if (!($acl = $this->getAcl())) {
// no acl registered means don't use acl
return true;
}
$role = $this->getRole();
$roles = $this->getRoles();
$resource = $page->getResource();
$privilege = $page->getPrivilege();
if (!$roles) {
$roles = array($roles);
}
if ($resource || $privilege) {
foreach ($roles as $r) {
// determine using helper role and page resource/privilege
return $acl->hasResource($resource) && $acl->isAllowed($r, $resource);
}
return false;
}
return true;
}