Neos\Neos\Service\ContentElementWrappingService::wrapContentObject PHP Method

wrapContentObject() public method

Wrap the $content identified by $node with the needed markup for the backend.
public wrapContentObject ( 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 wrapContentObject(NodeInterface $node, $content, $typoScriptPath)
    {
        if ($this->needsMetadata($node, false) === false) {
            return $content;
        }
        $attributes = [];
        $attributes['data-node-__typoscript-path'] = $typoScriptPath;
        $attributes['tabindex'] = 0;
        $attributes = $this->addGenericEditingMetadata($attributes, $node);
        $attributes = $this->addNodePropertyAttributes($attributes, $node);
        $attributes = $this->addCssClasses($attributes, $node, $this->collectEditingClassNames($node));
        return $this->htmlAugmenter->addAttributes($content, $attributes, 'div', array('typeof'));
    }

Usage Example

Example #1
0
 /**
  * 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());
 }
All Usage Examples Of Neos\Neos\Service\ContentElementWrappingService::wrapContentObject