Exemplo n.º 1
0
 /**
  * testSetParentRoleId
  *
  * @return void
  */
 public function testSetParentRoleId()
 {
     $aclRole = new AclRole();
     $parentAclRole = new AclRole();
     $parentAclRole->setRoleId('2222');
     $aclRole->setParentRoleId('');
     $this->assertNull($aclRole->getParentRoleId(), 'Role id that is set empty should be null');
     $aclRole->setParentRole($parentAclRole);
     $this->assertEquals($parentAclRole->getRoleId(), $aclRole->getParentRoleId(), 'Parent role id not populated.');
     $aclRole->setParentRoleId('3333');
     $this->assertNull($aclRole->getParentRole(), 'New parent id should clear parent role object');
 }
Exemplo n.º 2
0
 /**
  * populate
  *
  * @param array|AclRole $data data to populate with
  *
  * @return void
  * @throws RcmUserException
  */
 public function populate($data = [])
 {
     if ($data instanceof AclRole) {
         $this->setRoleId($data->getRoleId());
         $this->setDescription($data->getDescription());
         $this->setParentRoleId($data->getParentRoleId());
         $parentRole = $data->getParentRole();
         if (!empty($parentRole)) {
             $this->setParentRole($parentRole);
         }
         return;
     }
     if (is_array($data)) {
         if (isset($data['roleId'])) {
             $this->setRoleId($data['roleId']);
         }
         if (isset($data['description'])) {
             $this->setDescription($data['description']);
         }
         if (isset($data['parentRoleId'])) {
             $this->setParentRoleId($data['parentRoleId']);
         }
         if (isset($data['parentRole'])) {
             $this->setParentRoleId($data['parentRole']);
         }
         return;
     }
     throw new RcmUserException('Role data could not be populated, data format not supported');
 }
Exemplo n.º 3
0
 /**
  * createNamespaceId
  *
  * @param AclRole $role     acl role
  * @param array   $aclRoles array of roles
  *
  * @return string
  */
 public function createNamespaceId(AclRole $role, $aclRoles)
 {
     $parentRoleId = $role->getParentRoleId();
     $ns = $role->getRoleId();
     if (!empty($parentRoleId)) {
         $parent = $aclRoles[$parentRoleId];
         $newns = $this->createNamespaceId($parent, $aclRoles, $ns);
         $ns = $newns . '.' . $ns;
     }
     return $ns;
 }
Exemplo n.º 4
0
 /**
  * createRoleNamespaceId
  *
  * @param AclRole $aclRole  aclRole
  * @param array   $aclRoles aclRoles
  * @param string  $nsChar   nsChar
  *
  * @return string
  */
 public function createRoleNamespaceId(AclRole $aclRole, $aclRoles, $nsChar = '.')
 {
     $parentId = $aclRole->getParentRoleId();
     $ns = $aclRole->getRoleId();
     if (!empty($parentId)) {
         $parent = $aclRoles[$parentId];
         $newns = $this->createRoleNamespaceId($parent, $aclRoles, $nsChar);
         $ns = $newns . $nsChar . $ns;
     }
     return $ns;
 }