Neos\Flow\Security\Authorization\PrivilegeManagerInterface::isGranted PHP Method

isGranted() public method

Returns TRUE, if the given privilege type is granted for the given subject based on the current security context.
public isGranted ( string $privilegeType, mixed $subject, string &$reason = '' ) : boolean
$privilegeType string The type of privilege that should be evaluated
$subject mixed The subject to check privileges for
$reason string This variable will be filled by a message giving information about the reasons for the result of this method
return boolean
    public function isGranted($privilegeType, $subject, &$reason = '');

Usage Example

 /**
  * Invokes the security interception
  *
  * @return boolean TRUE if the security checks was passed
  * @throws AccessDeniedException
  * @throws AuthenticationRequiredException if an entity could not be found (assuming it is bound to the current session), causing a redirect to the authentication entrypoint
  * @throws NoTokensAuthenticatedException if no tokens could be found and the accessDecisionManager denied access to the privilege target, causing a redirect to the authentication entrypoint
  */
 public function invoke()
 {
     $reason = '';
     $privilegeSubject = new MethodPrivilegeSubject($this->joinPoint);
     try {
         $this->authenticationManager->authenticate();
     } catch (EntityNotFoundException $exception) {
         throw new AuthenticationRequiredException('Could not authenticate. Looks like a broken session.', 1358971444, $exception);
     } catch (NoTokensAuthenticatedException $noTokensAuthenticatedException) {
         // We still need to check if the privilege is available to "Neos.Flow:Everybody".
         if ($this->privilegeManager->isGranted(MethodPrivilegeInterface::class, $privilegeSubject, $reason) === false) {
             throw new NoTokensAuthenticatedException($noTokensAuthenticatedException->getMessage() . chr(10) . $reason, $noTokensAuthenticatedException->getCode());
         }
     }
     if ($this->privilegeManager->isGranted(MethodPrivilegeInterface::class, $privilegeSubject, $reason) === false) {
         throw new AccessDeniedException($this->renderDecisionReasonMessage($reason), 1222268609);
     }
 }
All Usage Examples Of Neos\Flow\Security\Authorization\PrivilegeManagerInterface::isGranted