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


PHP Zend_Acl::inheritsRole方法代碼示例

本文整理匯總了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));
 }
開發者ID:kandy,項目名稱:system,代碼行數:12,代碼來源:OptionsTest.php

示例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));
 }
開發者ID:kandy,項目名稱:system,代碼行數:14,代碼來源:DbTest.php

示例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));
 }
開發者ID:benivaldo,項目名稱:zf2-na-pratica,代碼行數:13,代碼來源:AclTest.php

示例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;
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:42,代碼來源:NavigationAbstract.php

示例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());
     }
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:22,代碼來源:AclTest.php

示例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];
     }
 }
開發者ID:harmslijper,項目名稱:gemstracker-library,代碼行數:20,代碼來源:DbLookup.php


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