当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractPage::getResource方法代码示例

本文整理汇总了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;
 }
开发者ID:siad007,项目名称:ctrllib,代码行数:44,代码来源:Menu.php

示例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;
 }
开发者ID:siad007,项目名称:ctrllib,代码行数:34,代码来源:Navigation.php


注:本文中的Zend\Navigation\Page\AbstractPage::getResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。