本文整理汇总了PHP中Zend_Acl::inheritsRole方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Acl::inheritsRole方法的具体用法?PHP Zend_Acl::inheritsRole怎么用?PHP Zend_Acl::inheritsRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Acl
的用法示例。
在下文中一共展示了Zend_Acl::inheritsRole方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLoadRoles
/**
* @covers System_Acl_Loader_Options::load
* @covers System_Acl_Loader_Options::<protected>
*/
public function testLoadRoles()
{
$this->object->setOptions($this->optionsHelper(System_Acl_Loader_Options::ROLES, array('test' => null, 'test1' => 'test')));
$this->object->load();
self::assertTrue($this->acl->hasRole('test'));
self::assertTrue($this->acl->hasRole('test1'));
self::assertTrue($this->acl->inheritsRole('test1', 'test', true));
}
示例2: testLoadRoles
/**
* @covers System_Acl_Loader_Db::load
* @covers System_Acl_Loader_Db::<protected>
*/
public function testLoadRoles()
{
$this->createTableMocks('AclResource');
$this->createTableMocks('AclRule');
$this->createTableMocks('AclRole', array(array('name' => 'test', 'parent' => null), array('name' => 'test1', 'parent' => 'test')));
$this->object->load();
self::assertTrue($this->acl->hasRole('test'));
self::assertTrue($this->acl->hasRole('test1'));
self::assertTrue($this->acl->inheritsRole('test1', 'test', true));
}
示例3: testRoleInheritanceSupportsCheckingOnlyParents
/**
* Ensures that the $onlyParents argument to inheritsRole() works
*
* @return void
* @group ZF-2502
*/
public function testRoleInheritanceSupportsCheckingOnlyParents()
{
$this->_acl->addRole(new Role\GenericRole('grandparent'))
->addRole(new Role\GenericRole('parent'), 'grandparent')
->addRole(new Role\GenericRole('child'), 'parent');
$this->assertFalse($this->_acl->inheritsRole('child', 'grandparent', true));
}
示例4: _acceptAcl
/**
* Determines whether a page should be accepted when iterating using ACL
*
* Validates that the role set in helper inherits or is the same as
* the role(s) found in the page
*
* @return bool
*/
protected function _acceptAcl(Zym_Navigation_Page $page, $recursive = true)
{
// do not accept by default
$accept = false;
if (!($helperRole = $this->getRole())) {
// don't accept if helper has no role
return false;
}
if (!($pageRole = $page->getRole())) {
// accept it if page has no role
$accept = true;
} else {
// loop all roles
foreach ($helperRole as $hRole) {
foreach ($pageRole as $pRole) {
if ($hRole == $pRole || $this->_acl->inheritsRole($hRole, $pRole)) {
$accept = true;
break;
}
}
if ($accept) {
break;
}
}
}
// loop parent(s) recursively if page is accepted and recurisve is true
if ($accept && $recursive) {
$parent = $page->getParent();
if ($parent instanceof Zym_Navigation_Page) {
$accept = $this->_acceptAcl($parent, true);
}
}
return $accept;
}
示例5: testRoleRegistryInheritsNonExistent
/**
* Ensures that an exception is thrown when a non-existent Role is specified to each parameter of inherits()
*
* @return void
*/
public function testRoleRegistryInheritsNonExistent()
{
$roleGuest = new Zend_Acl_Role('guest');
$this->_acl->addRole($roleGuest);
try {
$this->_acl->inheritsRole('nonexistent', $roleGuest);
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent child Role');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('not found', $e->getMessage());
}
try {
$this->_acl->inheritsRole($roleGuest, 'nonexistent');
$this->fail('Expected Zend_Acl_Role_Registry_Exception not thrown upon specifying a non-existent parent Role');
} catch (Zend_Acl_Role_Registry_Exception $e) {
$this->assertContains('not found', $e->getMessage());
}
}
示例6: getDefaultGroup
public function getDefaultGroup()
{
$groups = $this->getActiveStaffGroups();
$roles = $this->db->fetchPairs('SELECT ggp_role, ggp_id_group FROM gems__groups WHERE ggp_group_active=1 AND ggp_staff_members=1 ORDER BY ggp_name');
$current = null;
foreach (array_reverse($this->acl->getRoles()) as $roleId) {
if (isset($roles[$roleId], $groups[$roles[$roleId]])) {
if ($current) {
if ($this->acl->inheritsRole($current, $roleId)) {
$current = $roleId;
}
} else {
$current = $roleId;
}
}
}
if (isset($roles[$current])) {
return $roles[$current];
}
}