hasRole() публичный Метод

Checks if a role exists
public hasRole ( string $roleIdentifier ) : boolean
$roleIdentifier string The role identifier, format: (:)
Результат boolean
Пример #1
0
 /**
  * Initializes the roles field by fetching the role objects referenced by the roleIdentifiers
  *
  * @return void
  */
 protected function initializeRoles()
 {
     if ($this->roles !== null) {
         return;
     }
     $this->roles = [];
     foreach ($this->roleIdentifiers as $key => $roleIdentifier) {
         // check for and clean up roles no longer available
         if ($this->policyService->hasRole($roleIdentifier)) {
             $this->roles[$roleIdentifier] = $this->policyService->getRole($roleIdentifier);
         } else {
             unset($this->roleIdentifiers[$key]);
         }
     }
 }
 /**
  * @test
  */
 public function hasRoleReturnsTrueIfTheSpecifiedRoleIsConfigured()
 {
     $this->mockPolicyConfiguration = ['roles' => ['Some.Package:SomeRole' => []]];
     $this->assertTrue($this->policyService->hasRole('Some.Package:SomeRole'));
 }
 /**
  * Replaces a role identifier not containing a "." into fully qualified role identifier from the Neos.Neos namespace.
  *
  * @param string $roleIdentifier
  * @return string
  * @throws NoSuchRoleException
  */
 protected function normalizeRoleIdentifier($roleIdentifier)
 {
     if (strpos($roleIdentifier, ':') === false) {
         $roleIdentifier = 'Neos.Neos:' . $roleIdentifier;
     }
     if (!$this->policyService->hasRole($roleIdentifier)) {
         throw new NoSuchRoleException(sprintf('The role %s does not exist.', $roleIdentifier), 1422540184);
     }
     return $roleIdentifier;
 }