Neos\Flow\Security\Account::hasRole PHP 메소드

hasRole() 공개 메소드

Return if the account has a certain role
public hasRole ( Role $role ) : boolean
$role Neos\Flow\Security\Policy\Role
리턴 boolean
    public function hasRole(Role $role)
    {
        $this->initializeRoles();
        return array_key_exists($role->getIdentifier(), $this->roles);
    }

Usage Example

 /**
  * @test
  */
 public function hasRoleReturnsFalseForAssignedButNonExistentRole()
 {
     $this->inject($this->account, 'roleIdentifiers', ['Acme.Demo:NoLongerThere', $this->administratorRole->getIdentifier()]);
     $this->assertTrue($this->account->hasRole($this->administratorRole));
     $this->assertFalse($this->account->hasRole(new Role('Acme.Demo:NoLongerThere')));
 }
All Usage Examples Of Neos\Flow\Security\Account::hasRole