本文整理汇总了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());
}
示例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];
}
示例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);
}