Nodes

PHP API of Nodes

Neos 9

This page is for Neos 9.0 with the new Event Sourced Content Repository.

As described in the concept nodes are the fundamental building blocks of the content repository.

#Node Read Model

Main read model of the ContentSubgraphInterface.
Immutable, Read Only. In case you want to modify it, you need
to create Commands and send them to ContentRepository::handle.
Identity of a Node

Traversing the graph
The node does not have structure information, i.e. no infos
about its children. To f.e. fetch children, you need to fetch
the subgraph and use findChildNodes on the subgraph:

php
$subgraph = $contentRepository->getContentGraph($node->workspaceName)->getSubgraph(
    $node->dimensionSpacePoint,
    $node->visibilityConstraints
);
$childNodes = $subgraph->findChildNodes($node->aggregateId, FindChildNodesFilter::create());

A note about the DimensionSpacePoint and the OriginDimensionSpacePoint
The Node::dimensionSpacePoint is the DimensionSpacePoint this node has been accessed in,
and NOT the DimensionSpacePoint where the node is "at home".
The DimensionSpacePoint where the node is (at home) is called the ORIGIN DimensionSpacePoint,
and this can be accessed using Node::originDimensionSpacePoint. If in doubt, you'll
usually need the DimensionSpacePoint instead of the OriginDimensionSpacePoint;
you'll only need the OriginDimensionSpacePoint when constructing commands on the write side.

Modification of Nodes

Nodes being readonly, can only be modified via commands.

Each Node has the following properties

  • contentRepositoryId The content-repository this Node belongs to
  • workspaceName The workspace of this Node
  • dimensionSpacePoint DimensionSpacePoint a node has been accessed in
  • aggregateId NodeAggregateId (identifier) of this node. This is part of the node's "Read Model" identity, which is defined in a NodeAddress
  • originDimensionSpacePoint The DimensionSpacePoint the node originates in. Usually needed to address a Node in a NodeAggregate in order to update it.
  • classification The classification (regular, root, tethered) of this node
  • nodeTypeName The node's node type name; always set, even if unknown to the NodeTypeManager
  • properties All properties of this node. References are NOT part of this API; To access references, ContentSubgraphInterface::findReferences() can be used; To read the serialized properties use PropertyCollection::serialized().
  • name The optional name of the node, describing its relation to its parent
  • tags explicit and inherited SubtreeTags of this node
  • timestamps Creation and modification timestamps of this node
  • visibilityConstraints Information which subgraph filter was used to access this node

Node names and paths

Before Neos 9, Node relations were always named, which was required to uniquely identify a Node by its path. A path is formed via all Node names up to the root. In Neos 9 Node names are optional and partly deprecated and thus absolute paths as well.

#Node Address

This describes a node's read model identity namely:

  • ContentRepositoryId
  • WorkspaceName
  • DimensionSpacePoint (not to be confused with the Node::$originDimensionSpacePoint
  • NodeAggregateId

The node address can be constructed via NodeAddress::fromNode() and serialized.

In combination the parts can be used to distinctly identify a single node.
By using the content graph for the content repository
one can build a subgraph with the right perspective to find this node:

php
$subgraph = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
    $nodeAddress->dimensionSpacePoint,
    VisibilityConstraints::withoutRestrictions()
);
$node = $subgraph->findNodeById($nodeAddress->aggregateId);

#NodeType

The NodeType is the schema which defines the properties, references, tethered child nodes, constraints, and overall experience for the Neos Ui.

In Neos 9 properties are serialised at write time and will be deserialised with the same algorithm like they were stored. In Neos 8, the current Node Types property type was used to find a deserialisations method. This means that NodeTypes are only used for the write site e.g for command handling. 

Nodes know their current node type name that modifying commands like SetProperties fetch the NodeType.

The NodeType is no longer part of the Node read model but must be fetched separately:

php
$nodeTypeManager = $contentRepository->getNodeTypeManager();
$nodeType = $nodeTypeManager->getNodeType($element->nodeTypeName);
if ($nodeType !== null) {
    // your code
}