/** * Shows a specific node * * @param string $identifier Specifies the node to look up * @param string $workspaceName Name of the workspace to use for querying the node * @param array $dimensions Optional list of dimensions and their values which should be used for querying the specified node * @return string */ public function showAction($identifier, $workspaceName = 'live', array $dimensions = array()) { $contentContext = $this->createContentContext($workspaceName, $dimensions); /** @var $node NodeInterface */ $node = $contentContext->getNodeByIdentifier($identifier); if ($node === null) { $this->addExistingNodeVariantInformationToResponse($identifier, $contentContext); $this->throwStatus(404); } $this->view->assignMultiple(array('node' => $node, 'convertedNodeProperties' => $this->nodePropertyConverterService->getPropertiesArray($node))); }
/** * Renders data attributes needed for the given node property. * * @param NodeInterface $node * @param string $propertyName * @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; }