Neos\ContentRepository\Domain\Service\Context::getNodeByIdentifier PHP Method

getNodeByIdentifier() public method

Get a node by identifier and this context
public getNodeByIdentifier ( string $identifier ) : Neos\ContentRepository\Domain\Model\NodeInterface
$identifier string The identifier of a node
return Neos\ContentRepository\Domain\Model\NodeInterface The node with the given identifier or NULL if no such node exists
    public function getNodeByIdentifier($identifier)
    {
        $node = $this->firstLevelNodeCache->getByIdentifier($identifier);
        if ($node !== false) {
            return $node;
        }
        $nodeData = $this->nodeDataRepository->findOneByIdentifier($identifier, $this->getWorkspace(), $this->dimensions);
        if ($nodeData !== null) {
            $node = $this->nodeFactory->createFromNodeData($nodeData, $this);
        } else {
            $node = null;
        }
        $this->firstLevelNodeCache->setByIdentifier($identifier, $node);
        return $node;
    }

Usage Example

 /**
  * Maps the property value (an array of node identifiers) to the Node objects if needed.
  *
  * @param array $value
  * @return array
  */
 protected function resolvePropertyReferences($value = [])
 {
     $nodes = array_map(function ($nodeIdentifier) {
         return $this->context->getNodeByIdentifier($nodeIdentifier);
     }, $value);
     return array_filter($nodes);
 }
All Usage Examples Of Neos\ContentRepository\Domain\Service\Context::getNodeByIdentifier