Neos\Flow\Security\Policy\PolicyService::getRole PHP Method

getRole() public method

Returns a Role object configured in the PolicyService
public getRole ( string $roleIdentifier ) : Role
$roleIdentifier string The role identifier of the role, format: (:)
return Role
    public function getRole($roleIdentifier)
    {
        if ($this->hasRole($roleIdentifier)) {
            return $this->roles[$roleIdentifier];
        }
        throw new NoSuchRoleException();
    }

Usage Example

 /**
  * Convert an object from $source to an object.
  *
  * @param mixed $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @return object the target type
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
 {
     try {
         $role = $this->policyService->getRole($source);
     } catch (NoSuchRoleException $exception) {
         return new Error('Could not find a role with the identifier "%s".', 1397212327, [$source]);
     }
     return $role;
 }
All Usage Examples Of Neos\Flow\Security\Policy\PolicyService::getRole