當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Resource::getResourceId方法代碼示例

本文整理匯總了PHP中Resource::getResourceId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Resource::getResourceId方法的具體用法?PHP Resource::getResourceId怎麽用?PHP Resource::getResourceId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Resource的用法示例。


在下文中一共展示了Resource::getResourceId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testMostSpecificRuleAppliesIfNoExactRuleIsFound

 public function testMostSpecificRuleAppliesIfNoExactRuleIsFound()
 {
     $this->repository->addRule($this->role1, $this->resource1, true);
     $this->repository->addRule($this->role1, $this->resource2, false);
     $rule = $this->repository->getMostApplyingRule($this->role2, $this->resource2);
     $this->assertSame($this->role1->getRoleId(), $rule->getRoleId());
     $this->assertSame($this->resource2->getResourceId(), $rule->getResourceId());
 }
開發者ID:heho,項目名稱:gatekeeper,代碼行數:8,代碼來源:RuleRepositoryTest.php

示例2: array

 /**
  * Returns the rules associated with a Resource and a Role, or null if no such rules exist
  *
  * If either $resource or $role is null, this means that the rules returned are for all Resources or all Roles,
  * respectively. Both can be null to return the default rule set for all Resources and all Roles.
  *
  * If the $create parameter is true, then a rule set is first created and then returned to the caller.
  *
  * @param  Zend\Acl\Resource $resource
  * @param  Zend\Acl\Role     $role
  * @param  boolean           $create
  * @return array|null
  */
 protected function &_getRules(Resource $resource = null, Role $role = null, $create = false)
 {
     // create a reference to null
     $null = null;
     $nullRef =& $null;
     // follow $resource
     do {
         if (null === $resource) {
             $visitor =& $this->_rules['allResources'];
             break;
         }
         $resourceId = $resource->getResourceId();
         if (!isset($this->_rules['byResourceId'][$resourceId])) {
             if (!$create) {
                 return $nullRef;
             }
             $this->_rules['byResourceId'][$resourceId] = array();
         }
         $visitor =& $this->_rules['byResourceId'][$resourceId];
     } while (false);
     // follow $role
     if (null === $role) {
         if (!isset($visitor['allRoles'])) {
             if (!$create) {
                 return $nullRef;
             }
             $visitor['allRoles']['byPrivilegeId'] = array();
         }
         return $visitor['allRoles'];
     }
     $roleId = $role->getRoleId();
     if (!isset($visitor['byRoleId'][$roleId])) {
         if (!$create) {
             return $nullRef;
         }
         $visitor['byRoleId'][$roleId]['byPrivilegeId'] = array();
     }
     return $visitor['byRoleId'][$roleId];
 }
開發者ID:rafalwrzeszcz,項目名稱:zf2,代碼行數:52,代碼來源:Acl.php

示例3: addRule

 /**
  * Adds a new rule, that allows/denies access on $resource to $role
  *
  * @param Role $role Role for the new rule
  * @param Resource $resource Resource for the new rule
  * @param bool $allowed Status of the new rule
  * @return void
  */
 public function addRule(Role $role, Resource $resource, $allowed)
 {
     $this->rules[] = new Rule($role->getRoleId(), $resource->getResourceId(), $allowed);
 }
開發者ID:heho,項目名稱:gatekeeper,代碼行數:12,代碼來源:RuleRepository.php


注:本文中的Resource::getResourceId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。