Exemplo n.º 1
0
 /**
  * Returns the roles in the acl
  *
  * @return array roleId => ucfirst(roleId)
  */
 public function getRoles()
 {
     $roles = array();
     if ($this->acl) {
         foreach ($this->acl->getRoles() as $role) {
             //Do not translate, only make first one uppercase
             $roles[$role] = ucfirst($role);
         }
     }
     return $roles;
 }
Exemplo n.º 2
0
 /**
  * @group ZF-8468
  */
 public function testgetRoles()
 {
     $this->assertEquals(array(), $this->_acl->getRoles());
     $roleGuest = new Role\GenericRole('guest');
     $this->_acl->addRole($roleGuest);
     $this->_acl->addRole(new Role\GenericRole('staff'), $roleGuest);
     $this->_acl->addRole(new Role\GenericRole('editor'), 'staff');
     $this->_acl->addRole(new Role\GenericRole('administrator'));
     $expected = array('guest', 'staff', 'editor', 'administrator');
     $this->assertEquals($expected, $this->_acl->getRoles());
 }
Exemplo n.º 3
0
 /**
  * Returns the roles in the acl with the privilege
  *
  * @return array roleId => ucfirst(roleId)
  */
 public function getRolesByPrivilege($privilege)
 {
     $roles = array();
     if ($this->acl) {
         foreach ($this->acl->getRoles() as $role) {
             if ($this->acl->isAllowed($role, null, $privilege)) {
                 //Do not translate, only make first one uppercase
                 $roles[$role] = ucfirst($role);
             }
         }
     }
     return $roles;
 }