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


PHP Zend_Acl::setRule方法代码示例

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


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

示例1: _addRules

 /**
  * Method used to add rules to the specified resource.
  */
 protected function _addRules($type = Zend_Acl::TYPE_ALLOW, array $rules, $resource, $resourceName)
 {
     foreach ($rules as $privilege => $ruleProperties) {
         // If the user sets the privilege value to a string, we will consider
         // this as the list of roles.
         if (!is_array($ruleProperties)) {
             $ruleProperties = array('roles' => $ruleProperties);
         }
         if ($privilege === 'all') {
             $privilege = null;
         }
         $roles = $ruleProperties['roles'];
         if (is_null($roles) || empty($roles)) {
             $section = 'rules';
             if ($type === Zend_Acl::TYPE_ALLOW) {
                 $section = 'allow ' . $section;
             } else {
                 $section = 'deny ' . $section;
             }
             throw new Zend_Application_Resource_Exception(sprintf($this->_missingPropertyMessage, 'roles', $section, 'resource ' . $resourceName));
         }
         $roles = explode(',', $roles);
         if ($roles[0] === 'all') {
             $roles = null;
         }
         $assert = null;
         if (isset($ruleProperties['assert']) && !empty($ruleProperties['assert'])) {
             $assert = $ruleProperties['assert'];
             $assert = new $assert();
         }
         $this->_acl->setRule(Zend_Acl::OP_ADD, $type, $roles, $resource, $privilege, $asset);
     }
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:36,代码来源:Acl.php

示例2: testSetRuleWorksWithResourceInterface

 public function testSetRuleWorksWithResourceInterface()
 {
     $roleGuest = new Role\GenericRole('guest');
     $this->_acl->addRole($roleGuest);
     $resourceFoo = new Resource\GenericResource('foo');
     $this->_acl->addResource($resourceFoo);
     $this->_acl->setRule(Acl\Acl::OP_ADD, Acl\Acl::TYPE_ALLOW, $roleGuest, $resourceFoo);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:8,代码来源:AclTest.php

示例3: buildAcl

 public function buildAcl()
 {
     if ($this->_acl !== null) {
         return $this->_acl;
     }
     $aclDefinition = Zym_Message_Dispatcher::get()->post('buildAcl')->getResult('buildAcl');
     $acl = new Zend_Acl();
     foreach ($aclDefinition as $module) {
         if (!$acl->has($module['resource'])) {
             $acl->addResource($module['resource']);
         }
         foreach ($module['rules'] as $key => $rule) {
             if (!$acl->hasRole($key)) {
                 $acl->addRole($key);
             }
             $acl->setRule('OP_ADD', $rule['allPrivileges']['type'], $key, $module['resource']);
         }
     }
     $this->_acl = $acl;
     return $this->_acl;
 }
开发者ID:rantoine,项目名称:AdvisorIllustrator,代码行数:21,代码来源:BuildAcl.php


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