Neos\Neos\Service\ContentElementWrappingService::wrapCurrentDocumentMetadata PHP Method

wrapCurrentDocumentMetadata() public method

public wrapCurrentDocumentMetadata ( Neos\ContentRepository\Domain\Model\NodeInterface $node, string $content, string $typoScriptPath ) : string
$node Neos\ContentRepository\Domain\Model\NodeInterface
$content string
$typoScriptPath string
return string
    public function wrapCurrentDocumentMetadata(NodeInterface $node, $content, $typoScriptPath)
    {
        if ($this->needsMetadata($node, true) === false) {
            return $content;
        }
        $attributes = [];
        $attributes['data-node-__typoscript-path'] = $typoScriptPath;
        $attributes = $this->addGenericEditingMetadata($attributes, $node);
        $attributes = $this->addNodePropertyAttributes($attributes, $node);
        $attributes = $this->addDocumentMetadata($attributes, $node);
        $attributes = $this->addCssClasses($attributes, $node, []);
        return $this->htmlAugmenter->addAttributes($content, $attributes, 'div', ['typeof']);
    }

Usage Example

コード例 #1
0
 /**
  * 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\Neos\Service\ContentElementWrappingService::wrapCurrentDocumentMetadata