当前位置: 首页>>代码示例>>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;未经允许,请勿转载。