コード例 #1
0
ファイル: Mysql.php プロジェクト: vegas-cmf/acl
 /**
  * Gets role with all its accesses
  * 
  * @param string $role
  * @return \Vegas\Security\Acl\Role
  */
 public function getRole($role)
 {
     if (!$role instanceof AclRole) {
         $role = $this->getRoleModel($role);
     }
     $roleObject = new Role($role->name, $role->description);
     $roleObject->setRemovable($role->removable);
     $roleObject->setId($role->id);
     foreach ($role->getAccessLists() as $access) {
         $roleObject->addAccess($access->toAccessArray());
     }
     return $roleObject;
 }
コード例 #2
0
ファイル: Mongo.php プロジェクト: vegas-cmf/acl
 /**
  * @param string|array $role
  * @return \Vegas\Security\Acl\Role
  * @throws Exception\RoleDoesNotExistException
  */
 public function getRole($role)
 {
     if ($role instanceof Role) {
         return $role;
     }
     $roleName = gettype($role) === 'array' ? $role['name'] : $role;
     $role = $this->getCollection('roles')->findOne(array('name' => $roleName));
     if (!$role) {
         throw new RoleDoesNotExistException($roleName);
     }
     $accessListArray = [];
     $accessList = $this->getRoleAccesses($role['name']);
     foreach ($accessList as $accessDocument) {
         $accessListArray[] = $accessDocument;
     }
     $roleObject = new Role($role['name'], $role['description']);
     $roleObject->setRemovable($role['removable']);
     $roleObject->setId($role['_id']);
     $roleObject->setAccessList((array) $accessList);
     $role = $roleObject;
     return $role;
 }
コード例 #3
0
ファイル: RoleTest.php プロジェクト: vegas-cmf/acl
 public function testGetId()
 {
     $id = 'foo';
     $this->obj->setId($id);
     $this->assertSame($id, $this->obj->getId());
 }