本文整理匯總了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;
}