當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。