예제 #1
0
 /**
  * testSetGet
  *
  * @return void
  */
 public function testSetGet()
 {
     $nameSpaceAclRole = new NamespaceAclRole('admin', 'guest');
     $nameSpaceAclRole->setRoleId('myrole');
     $ns = $nameSpaceAclRole->getNamespace();
     $this->assertEquals('myrole', $ns);
     $nameSpaceAclRole->setNamespace('TESTNS');
     $ns = $nameSpaceAclRole->getNamespace();
     $this->assertEquals('TESTNS', $ns);
     $obj = $nameSpaceAclRole->jsonSerialize();
     $this->assertEquals('TESTNS', $obj->namespace);
 }
예제 #2
0
 /**
  * getNamespacedRoles
  *
  * @param string $nsChar nsChar
  *
  * @return array
  */
 public function getNamespacedRoles($nsChar = '.')
 {
     $aclRoles = array();
     $result = $this->getAllRoles();
     if (!$result->isSuccess()) {
         return $result;
     }
     $roles = $result->getData();
     foreach ($roles as $role) {
         $ns = $this->createRoleNamespaceId($role, $roles, $nsChar);
         $nsRole = new NamespaceAclRole($this->getSuperAdminRoleId()->getData(), $this->getGuestRoleId()->getData());
         $nsRole->populate($role);
         $nsRole->setNamespace($ns);
         $aclRoles[$ns] = $nsRole;
     }
     ksort($aclRoles);
     return new Result($aclRoles, Result::CODE_SUCCESS);
 }