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


PHP Zend_Acl::get方法代码示例

本文整理汇总了PHP中Zend_Acl::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Acl::get方法的具体用法?PHP Zend_Acl::get怎么用?PHP Zend_Acl::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Acl的用法示例。


在下文中一共展示了Zend_Acl::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isAllowed

 /**
  * Notifies whether the logged-in user has permission for a given resource/
  * privilege combination.
  *
  * If an ACL resource being checked has not been defined, access to that
  * resource should not be controlled.  This allows plugin writers to
  * implement controllers without also requiring them to be aware of the ACL.
  *
  * Conversely, in the event that an ACL resource has been defined, all access
  * permissions for that controller must be properly defined.
  *
  * The names of resources should correspond to the name of the controller
  * class minus 'Controller', e.g.
  * Geolocation_IndexController -> 'Geolocation_Index'
  * CollectionsController -> 'Collections'
  *
  * @param string $privilege
  * @param Zend_Acl_Resource|string|null (Optional) Resource to check.
  * @see getResourceName()
  * @return boolean
  */
 public function isAllowed($privilege, $resource = null)
 {
     $allowed = $this->_allowed;
     if (isset($allowed[$privilege])) {
         return $allowed[$privilege];
     }
     if ($resource instanceof Zend_Acl_Resource_Interface) {
         $resourceObj = $resource;
         $resourceName = $resourceObj->getResourceId();
     } else {
         if (is_string($resource)) {
             $resourceName = $resource;
         } else {
             if (!$resource) {
                 $resourceName = $this->getResourceName();
             }
         }
     }
     // Plugin writers do not need to define an ACL in order for their
     // controllers to work.
     if (!$this->_acl->has($resourceName)) {
         return true;
     }
     if (!isset($resourceObj)) {
         $resourceObj = $this->_acl->get($resourceName);
     }
     return $this->_acl->isAllowed($this->_currentUser, $resourceObj, $privilege);
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:49,代码来源:Acl.php

示例2: testResourceAddAndGetOne

 /**
  * Ensures that basic addition and retrieval of a single Resource works
  *
  * @return void
  */
 public function testResourceAddAndGetOne()
 {
     $resourceArea = new Zend_Acl_Resource('area');
     $resource = $this->_acl->add($resourceArea)->get($resourceArea->getResourceId());
     $this->assertTrue($resourceArea === $resource);
     $resource = $this->_acl->get($resourceArea);
     $this->assertTrue($resourceArea === $resource);
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:13,代码来源:AclTest.php

示例3: _registerResource

 protected function _registerResource($resourceName)
 {
     $parentRole = null;
     $currentResourceName = '';
     foreach (explode('.', $resourceName) as $resourceNamePart) {
         $currentResourceName = trim($currentResourceName . '.' . $resourceNamePart, '.');
         if (!$this->_acl->has($currentResourceName)) {
             $this->_acl->addResource($currentResourceName, $parentRole);
         }
         $parentRole = $this->_acl->get($currentResourceName);
     }
 }
开发者ID:kandy,项目名称:system,代码行数:12,代码来源:Acl.php

示例4: get

 /** @brief	Renvoie la resource
  *
  * Crée la ressource si elle n'existe pas
  * La surcharge de cette méthode de Zend_Acl permet de créer automatiquement
  * la ressource si elle n'existe pas quand on fait des allow ou des deny
  * par exemple.
  *
  * @author amboise.lafont
  */
 public function get($resource)
 {
     if (!$this->has($resource)) {
         $this->addResource($resource);
     }
     return parent::get($resource);
 }
开发者ID:netixx,项目名称:Stock,代码行数:16,代码来源:Acl.php


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