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

isPrivilegeTargetGranted() public method

Returns TRUE if access is granted on the given privilege target in the current security context
public isPrivilegeTargetGranted ( string $privilegeTargetIdentifier, array $privilegeParameters = [] ) : boolean
$privilegeTargetIdentifier string The identifier of the privilege target to decide on
$privilegeParameters array Optional array of privilege parameters (simple key => value array)
return boolean TRUE if access is granted, FALSE otherwise
    public function isPrivilegeTargetGranted($privilegeTargetIdentifier, array $privilegeParameters = []);

Usage Example

 /**
  * Handle an exception by displaying an error message inside the Neos backend, if logged in and not displaying the live workspace.
  *
  * @param array $typoScriptPath path causing the exception
  * @param \Exception $exception exception to handle
  * @param integer $referenceCode
  * @return string
  */
 protected function handle($typoScriptPath, \Exception $exception, $referenceCode)
 {
     $handler = new ContextDependentHandler();
     $handler->setRuntime($this->runtime);
     $output = $handler->handleRenderingException($typoScriptPath, $exception);
     $currentContext = $this->runtime->getCurrentContext();
     /** @var NodeInterface $documentNode */
     $documentNode = isset($currentContext['documentNode']) ? $currentContext['documentNode'] : null;
     /** @var NodeInterface $node */
     $node = isset($currentContext['node']) ? $currentContext['node'] : null;
     $fluidView = $this->prepareFluidView();
     $isBackend = false;
     /** @var NodeInterface $siteNode */
     $siteNode = isset($currentContext['site']) ? $currentContext['site'] : null;
     if ($documentNode === null) {
         // Actually we cannot be sure that $node is a document. But for fallback purposes this should be safe.
         $documentNode = $siteNode ? $siteNode : $node;
     }
     if ($documentNode !== null && $documentNode->getContext()->getWorkspace()->getName() !== 'live' && $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) {
         $isBackend = true;
         $fluidView->assign('metaData', $this->contentElementWrappingService->wrapCurrentDocumentMetadata($documentNode, '<div id="neos-document-metadata"></div>', $typoScriptPath));
     }
     $fluidView->assignMultiple(array('isBackend' => $isBackend, 'message' => $output, 'node' => $node));
     return $fluidView->render();
 }
All Usage Examples Of Neos\Flow\Security\Authorization\PrivilegeManagerInterface::isPrivilegeTargetGranted