/** * 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(); }
/** * Evaluate this TypoScript object and return the result * * @return mixed */ public function evaluate() { $content = $this->getValue(); /** @var $node NodeInterface */ $node = $this->tsValue('node'); if (!$node instanceof NodeInterface) { return $content; } /** @var $contentContext ContentContext */ $contentContext = $node->getContext(); if ($contentContext->getWorkspaceName() === 'live') { return $content; } if (!$this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) { return $content; } if ($node->isRemoved()) { $content = ''; } if ($this->tsValue('renderCurrentDocumentMetadata')) { return $this->contentElementWrappingService->wrapCurrentDocumentMetadata($node, $content, $this->getContentElementTypoScriptPath()); } return $this->contentElementWrappingService->wrapContentObject($node, $content, $this->getContentElementTypoScriptPath()); }