/** * 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('TYPO3.Neos:Backend.GeneralAccess')) { $isBackend = true; $fluidView->assign('metaData', $this->contentElementWrappingService->wrapContentObject($documentNode, $typoScriptPath, '<div id="neos-document-metadata"></div>', true)); } $fluidView->assignMultiple(array('isBackend' => $isBackend, 'message' => $output, 'node' => $node)); return $fluidView->render(); }
/** * In live workspace this just renders a the content. * For logged in users with access to the Backend this also adds the attributes for the RTE to work. * * @param NodeInterface $node The node of the content element. Optional, will be resolved from the TypoScript context by default. * @return string The rendered property with a wrapping tag. In the user workspace this adds some required attributes for the RTE to work * @throws ViewHelperException */ public function render(NodeInterface $node = null) { $view = $this->viewHelperVariableContainer->getView(); if (!$view instanceof TypoScriptAwareViewInterface) { throw new ViewHelperException('This ViewHelper can only be used in a TypoScript content element. You have to specify the "node" argument if it cannot be resolved from the TypoScript context.', 1385737102); } $typoScriptObject = $view->getTypoScriptObject(); $currentContext = $typoScriptObject->getTsRuntime()->getCurrentContext(); if ($node === null) { $node = $currentContext['node']; } return $this->contentElementWrappingService->wrapContentObject($node, $this->renderChildren(), $typoScriptObject->getPath()); }
/** * renders the exception to nice html content element to display, edit, remove, ... * * @param string $typoScriptPath - path causing the exception * @param \Exception $exception - exception to handle * @param integer $referenceCode - might be unset * @return string */ protected function handle($typoScriptPath, \Exception $exception, $referenceCode) { $handler = new ContextDependentHandler(); $handler->setRuntime($this->runtime); $output = $handler->handleRenderingException($typoScriptPath, $exception); $currentContext = $this->getRuntime()->getCurrentContext(); if (isset($currentContext['node'])) { /** @var NodeInterface $node */ $node = $currentContext['node']; $applicationContext = $this->environment->getContext(); if ($applicationContext->isProduction() && $this->privilegeManager->isPrivilegeTargetGranted('TYPO3.Neos:Backend.GeneralAccess') && $node->getContext()->getWorkspaceName() !== 'live') { $output = '<div class="neos-rendering-exception"><div class="neos-rendering-exception-title">Failed to render element' . $output . '</div></div>'; } return $this->contentElementWrappingService->wrapContentObject($node, $output, $typoScriptPath); } return $output; }
/** * Evaluate this TypoScript object and return the result * * @return mixed * @throws \TYPO3\Neos\Domain\Exception */ 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('TYPO3.Neos:Backend.GeneralAccess')) { return $content; } if ($node->isRemoved()) { $content = ''; } return $this->contentElementWrappingService->wrapContentObject($node, $this->getContentElementTypoScriptPath(), $content, $this->tsValue('renderCurrentDocumentMetadata')); }