Neos\Neos\Service\ContentElementWrappingService::renderNodePropertyAttribute PHP Method

renderNodePropertyAttribute() protected method

Renders data attributes needed for the given node property.
protected renderNodePropertyAttribute ( Neos\ContentRepository\Domain\Model\NodeInterface $node, string $propertyName ) : array
$node Neos\ContentRepository\Domain\Model\NodeInterface
$propertyName string
return array
    protected function renderNodePropertyAttribute(NodeInterface $node, $propertyName)
    {
        $attributes = [];
        /** @var $contentContext ContentContext */
        $contentContext = $node->getContext();
        // skip the node name of the site node - TODO: Why do we need this?
        if ($propertyName === '_name' && $node === $contentContext->getCurrentSiteNode()) {
            return $attributes;
        }
        $dataType = $node->getNodeType()->getPropertyType($propertyName);
        $dasherizedPropertyName = $this->dasherize($propertyName);
        $propertyValue = $this->nodePropertyConverterService->getProperty($node, $propertyName);
        $propertyValue = $propertyValue === null ? '' : $propertyValue;
        $propertyValue = !is_string($propertyValue) ? json_encode($propertyValue) : $propertyValue;
        if ($dataType !== 'string') {
            $attributes['data-nodedatatype-' . $dasherizedPropertyName] = 'xsd:' . $dataType;
        }
        $attributes['data-node-' . $dasherizedPropertyName] = $propertyValue;
        return $attributes;
    }