interface NodeInterface (View source)

Interface for a Node. This is the central interface for the Neos Content Repository.

Note: This will be replaced by {\Neos\ContentRepository\Domain\Model\Neos\ContentRepository\Domain\Projection\Content\TraversableNodeInterface} at some point

Constants

MATCH_PATTERN_PATH

Regex pattern which matches a node path without any context information

MATCH_PATTERN_CONTEXTPATH

Regex pattern which matches a "context path", ie. a node path possibly containing context information such as the workspace name. This pattern is used at least in the route part handler.

MATCH_PATTERN_NAME

Regex pattern which matches a Node Name (ie. segment of a node path)

Methods

void
setName(string $newName)

Set the name of the node to $newName, keeping it's position as it is

string
getName() deprecated

Returns the name of this node

string
getLabel()

Returns a full length plain text label of this node

void
setProperty(string $propertyName, mixed $value)

Sets the specified property.

bool
hasProperty(string $propertyName)

If this node has a property with the given name.

mixed
getProperty(string $propertyName)

Returns the specified property.

void
removeProperty(string $propertyName)

Removes the specified property.

getProperties()

Returns all properties of this node.

string[]
getPropertyNames()

Returns the names of all properties of this node.

void
setContentObject(object $contentObject) deprecated

Sets a content object for this node.

object
getContentObject() deprecated

Returns the content object of this node (if any).

void
unsetContentObject() deprecated

Unsets the content object of this node.

void
setNodeType(NodeType $nodeType)

Sets the node type of this node.

getNodeType()

Returns the node type of this node.

void
setHidden(bool $hidden)

Sets the "hidden" flag for this node.

bool
isHidden()

Returns the current state of the hidden flag

void
setHiddenBeforeDateTime(DateTimeInterface $dateTime = null)

Sets the date and time when this node becomes potentially visible.

getHiddenBeforeDateTime()

Returns the date and time before which this node will be automatically hidden.

void
setHiddenAfterDateTime(DateTimeInterface $dateTime = null)

Sets the date and time when this node should be automatically hidden

getHiddenAfterDateTime()

Returns the date and time after which this node will be automatically hidden.

void
setHiddenInIndex(bool $hidden)

Sets if this node should be hidden in indexes, such as a site navigation.

bool
isHiddenInIndex()

If this node should be hidden in indexes

void
setAccessRoles(array $accessRoles) deprecated

Sets the roles which are required to access this node

array
getAccessRoles() deprecated

Returns the names of defined access roles

string
getPath() deprecated

Returns the path of this node

string
getContextPath()

Returns the absolute path of this node with additional context information (such as the workspace name).

int
getDepth() deprecated

Returns the level at which this node is located.

void
setWorkspace(Workspace $workspace)

Sets the workspace of this node.

getWorkspace()

Returns the workspace this node is contained in

string
getIdentifier() deprecated

Returns the identifier of this node.

void
setIndex(int $index)

Sets the index of this node

int
getIndex()

Returns the index of this node which determines the order among siblings with the same parent node.

getParent() deprecated

Returns the parent node of this node

string
getParentPath() deprecated

Returns the parent node path

createNode(string $name, NodeType $nodeType = null, string $identifier = null)

Creates, adds and returns a child node of this node. Also sets default properties and creates default subnodes.

createSingleNode(string $name, NodeType $nodeType = null, string $identifier = null)

Creates, adds and returns a child node of this node, without setting default properties or creating subnodes.

createNodeFromTemplate(NodeTemplate $nodeTemplate, string $nodeName = null)

Creates and persists a node from the given $nodeTemplate as child node

getNode(string $path) deprecated

Returns a node specified by the given relative path.

getPrimaryChildNode() deprecated

Returns the primary child node of this node.

getChildNodes(string $nodeTypeFilter = null, int $limit = null, int $offset = null) deprecated

Returns all direct child nodes of this node.

bool
hasChildNodes(string $nodeTypeFilter = null) deprecated

Checks if this node has any child nodes.

void
remove()

Removes this node and all its child nodes. This is an alias for setRemoved(true)

void
setRemoved(bool $removed)

Removes this node and all its child nodes or sets ONLY this node to not being removed.

bool
isRemoved()

If this node is a removed node.

bool
isVisible()

Tells if this node is "visible".

bool
isAccessible() deprecated

Tells if this node may be accessed according to the current security context.

bool
hasAccessRestrictions() deprecated

Tells if a node, in general, has access restrictions, independent of the current security context.

bool
isNodeTypeAllowedAsChildNode(NodeType $nodeType)

Checks if the given $nodeType would be allowed as a child node of this node according to the configured constraints.

void
moveBefore(NodeInterface $referenceNode)

Moves this node before the given node

void
moveAfter(NodeInterface $referenceNode)

Moves this node after the given node

void
moveInto(NodeInterface $referenceNode)

Moves this node into the given node

copyBefore(NodeInterface $referenceNode, string $nodeName)

Copies this node before the given node

copyAfter(NodeInterface $referenceNode, string $nodeName)

Copies this node after the given node

copyInto(NodeInterface $referenceNode, string $nodeName)

Copies this node to below the given node. The new node will be added behind any existing sub nodes of the given node.

getNodeData()

Return the NodeData representation of the node.

getContext()

Return the context of the node

array
getDimensions()

Return the assigned content dimensions of the node.

createVariantForContext(Context $context)

Given a context a new node is returned that is like this node, but lives in the new context.

bool
isAutoCreated() deprecated

Determine if this node is configured as auto-created childNode of the parent node. If that is the case, it should not be deleted.

getOtherNodeVariants()

Get other variants of this node (with different dimension values)

Details

void setName(string $newName)

Set the name of the node to $newName, keeping it's position as it is

Parameters

string $newName

Return Value

void

Exceptions

InvalidArgumentException

string getName() deprecated

deprecated with version 4.3, use TraversableNodeInterface::getNodeName() instead.

Returns the name of this node

Return Value

string

string getLabel()

Returns a full length plain text label of this node

Return Value

string

void setProperty(string $propertyName, mixed $value)

Sets the specified property.

If the node has a content object attached, the property will be set there if it is settable.

Parameters

string $propertyName

Name of the property

mixed $value

Value of the property

Return Value

void

bool hasProperty(string $propertyName)

If this node has a property with the given name.

If the node has a content object attached, the property will be checked there.

Parameters

string $propertyName

Name of the property to test for

Return Value

bool

mixed getProperty(string $propertyName)

Returns the specified property.

If the node has a content object attached, the property will be fetched there if it is gettable.

Parameters

string $propertyName

Name of the property

Return Value

mixed

value of the property

Exceptions

NodeException

void removeProperty(string $propertyName)

Removes the specified property.

If the node has a content object attached, the property will not be removed on that object if it exists.

Parameters

string $propertyName

Name of the property

Return Value

void

Exceptions

NodeException

PropertyCollectionInterface getProperties()

Returns all properties of this node.

If the node has a content object attached, the properties will be fetched there.

Return Value

PropertyCollectionInterface

Property values

string[] getPropertyNames()

Returns the names of all properties of this node.

Return Value

string[]

Property names

void setContentObject(object $contentObject) deprecated

deprecated with version 4.3. Attaching entities to nodes never really worked. Instead you can reference objects as node properties via their identifier

Sets a content object for this node.

Parameters

object $contentObject

The content object

Return Value

void

Exceptions

InvalidArgumentException

object getContentObject() deprecated

deprecated with version 4.3. Attaching entities to nodes never really worked. Instead you can reference objects as node properties via their identifier

Returns the content object of this node (if any).

Return Value

object

The content object or NULL if none was set

void unsetContentObject() deprecated

deprecated with version 4.3. Attaching entities to nodes never really worked. Instead you can reference objects as node properties via their identifier

Unsets the content object of this node.

Return Value

void

void setNodeType(NodeType $nodeType)

Sets the node type of this node.

Parameters

NodeType $nodeType

Return Value

void

NodeType getNodeType()

Returns the node type of this node.

Return Value

NodeType

void setHidden(bool $hidden)

Sets the "hidden" flag for this node.

Parameters

bool $hidden

If true, this Node will be hidden

Return Value

void

bool isHidden()

Returns the current state of the hidden flag

Return Value

bool

void setHiddenBeforeDateTime(DateTimeInterface $dateTime = null)

Sets the date and time when this node becomes potentially visible.

Parameters

DateTimeInterface $dateTime

Date before this node should be hidden

Return Value

void

DateTimeInterface|null getHiddenBeforeDateTime()

Returns the date and time before which this node will be automatically hidden.

Return Value

DateTimeInterface|null

Date before this node will be hidden - or null if no hidden before date is set

void setHiddenAfterDateTime(DateTimeInterface $dateTime = null)

Sets the date and time when this node should be automatically hidden

Parameters

DateTimeInterface $dateTime

Date after which this node should be hidden

Return Value

void

DateTimeInterface|null getHiddenAfterDateTime()

Returns the date and time after which this node will be automatically hidden.

Return Value

DateTimeInterface|null

Date after which this node will be hidden - or null if no hidden after date is set

void setHiddenInIndex(bool $hidden)

Sets if this node should be hidden in indexes, such as a site navigation.

Parameters

bool $hidden

true if it should be hidden, otherwise false

Return Value

void

bool isHiddenInIndex()

If this node should be hidden in indexes

Return Value

bool

void setAccessRoles(array $accessRoles) deprecated

deprecated with version 4.3. Use a Policy to restrict access to nodes

Sets the roles which are required to access this node

Parameters

array $accessRoles

Return Value

void

array getAccessRoles() deprecated

deprecated with version 4.3. Use a Policy to restrict access to nodes

Returns the names of defined access roles

Return Value

array

string getPath() deprecated

deprecated with version 4.3, use TraversableNodeInterface::findNodePath() instead.

Returns the path of this node

Example: /sites/mysitecom/homepage/about

Return Value

string

The absolute node path

string getContextPath()

Returns the absolute path of this node with additional context information (such as the workspace name).

Example: /sites/mysitecom/homepage/about@user-admin

NOTE: This method will probably be removed at some point. Code should never rely on the exact format of the context path since that might change in the future.

Return Value

string

Node path with context information

int getDepth() deprecated

deprecated with version 4.3 - Use TraversableNodeInterface::findNodePath()->getDepth() instead

Returns the level at which this node is located.

Counting starts with 0 for "/", 1 for "/foo", 2 for "/foo/bar" etc.

Return Value

int

void setWorkspace(Workspace $workspace)

Sets the workspace of this node.

This method is only for internal use by the content repository. Changing the workspace of a node manually may lead to unexpected behavior.

Parameters

Workspace $workspace

Return Value

void

Workspace getWorkspace()

Returns the workspace this node is contained in

Return Value

Workspace

string getIdentifier() deprecated

deprecated with version 4.3, use getNodeAggregateIdentifier() instead.

Returns the identifier of this node.

This UUID is not the same as the technical persistence identifier used by Flow's persistence framework. It is an additional identifier which is unique within the same workspace and is used for tracking the same node in across workspaces.

It is okay and recommended to use this identifier for synchronisation purposes as it does not change even if all of the nodes content or its path changes.

Return Value

string

the node's UUID

void setIndex(int $index)

Sets the index of this node

This method is for internal use and must only be used by other nodes!

Parameters

int $index

The new index

Return Value

void

int getIndex()

Returns the index of this node which determines the order among siblings with the same parent node.

Return Value

int

NodeInterface getParent() deprecated

deprecated with version 4.3, use TraversableNodeInterface::findParentNode() instead. Beware that findParentNode() is not fully equivalent to this method. It has a different root node handling: - findParentNode() throws an exception for the root node - getParent() returns null for the root node

Returns the parent node of this node

Return Value

NodeInterface

The parent node or NULL if this is the root node

string getParentPath() deprecated

deprecated with version 4.3, use TraversableNodeInterface::findParentNode()->findNodePath() instead.

Returns the parent node path

Return Value

string

Absolute node path of the parent node

NodeInterface createNode(string $name, NodeType $nodeType = null, string $identifier = null)

Creates, adds and returns a child node of this node. Also sets default properties and creates default subnodes.

Parameters

string $name

Name of the new node

NodeType $nodeType

Node type of the new node (optional)

string $identifier

The identifier of the node, unique within the workspace, optional(!)

Return Value

NodeInterface

Exceptions

InvalidArgumentException
NodeExistsException

NodeInterface createSingleNode(string $name, NodeType $nodeType = null, string $identifier = null)

Creates, adds and returns a child node of this node, without setting default properties or creating subnodes.

For internal use only!

Parameters

string $name

Name of the new node

NodeType $nodeType

Node type of the new node (optional)

string $identifier

The identifier of the node, unique within the workspace, optional(!)

Return Value

NodeInterface

Exceptions

InvalidArgumentException
NodeExistsException

NodeInterface createNodeFromTemplate(NodeTemplate $nodeTemplate, string $nodeName = null)

Creates and persists a node from the given $nodeTemplate as child node

Parameters

NodeTemplate $nodeTemplate
string $nodeName

name of the new node. If not specified the name of the nodeTemplate will be used.

Return Value

NodeInterface

the freshly generated node

NodeInterface getNode(string $path) deprecated

deprecated with version 4.3 - use TraversableNodeInterface::findNamedChildNode() instead

Returns a node specified by the given relative path.

Parameters

string $path

Path specifying the node, relative to this node

Return Value

NodeInterface

The specified node or NULL if no such node exists

NodeInterface getPrimaryChildNode() deprecated

deprecated with version 4.3. use TraversableNodeInterface::findChildNodes() instead, the first result is considered the "primary child node"

Returns the primary child node of this node.

Which node acts as a primary child node will in the future depend on theLayeredWorkspacesTest node type. For now it is just the first child node.

Return Value

NodeInterface

The primary child node or NULL if no such node exists

NodeInterface[] getChildNodes(string $nodeTypeFilter = null, int $limit = null, int $offset = null) deprecated

deprecated with version 4.3, use TraversableNodeInterface::findChildNodes() instead.

Returns all direct child nodes of this node.

If a node type is specified, only nodes of that type are returned.

Parameters

string $nodeTypeFilter

If specified, only nodes with that node type are considered

int $limit

An optional limit for the number of nodes to find. Added or removed nodes can still change the number nodes!

int $offset

An optional offset for the query

Return Value

NodeInterface[]

An array of nodes or an empty array if no child nodes matched

bool hasChildNodes(string $nodeTypeFilter = null) deprecated

deprecated with version 4.3, use TraversableNodeInterface::findChildNodes() instead and count the result

Checks if this node has any child nodes.

Parameters

string $nodeTypeFilter

If specified, only nodes with that node type are considered

Return Value

bool

true if this node has child nodes, otherwise false

void remove()

Removes this node and all its child nodes. This is an alias for setRemoved(true)

Return Value

void

void setRemoved(bool $removed)

Removes this node and all its child nodes or sets ONLY this node to not being removed.

Parameters

bool $removed

If true, this node and it's child nodes will be removed or set to be not removed.

Return Value

void

bool isRemoved()

If this node is a removed node.

Return Value

bool

bool isVisible()

Tells if this node is "visible".

For this the "hidden" flag and the "hiddenBeforeDateTime" and "hiddenAfterDateTime" dates are taken into account.

Return Value

bool

bool isAccessible() deprecated

deprecated with version 4.3. Use a Policy to restrict access to nodes

Tells if this node may be accessed according to the current security context.

Return Value

bool

bool hasAccessRestrictions() deprecated

deprecated with version 4.3. Use a Policy to restrict access to nodes

Tells if a node, in general, has access restrictions, independent of the current security context.

Return Value

bool

bool isNodeTypeAllowedAsChildNode(NodeType $nodeType)

Checks if the given $nodeType would be allowed as a child node of this node according to the configured constraints.

Parameters

NodeType $nodeType

Return Value

bool

true if the passed $nodeType is allowed as child node

void moveBefore(NodeInterface $referenceNode)

Moves this node before the given node

Parameters

NodeInterface $referenceNode

Return Value

void

void moveAfter(NodeInterface $referenceNode)

Moves this node after the given node

Parameters

NodeInterface $referenceNode

Return Value

void

void moveInto(NodeInterface $referenceNode)

Moves this node into the given node

Parameters

NodeInterface $referenceNode

Return Value

void

NodeInterface copyBefore(NodeInterface $referenceNode, string $nodeName)

Copies this node before the given node

Parameters

NodeInterface $referenceNode
string $nodeName

Return Value

NodeInterface

The copied node

Exceptions

NodeExistsException

NodeInterface copyAfter(NodeInterface $referenceNode, string $nodeName)

Copies this node after the given node

Parameters

NodeInterface $referenceNode
string $nodeName

Return Value

NodeInterface

The copied node

Exceptions

NodeExistsException

NodeInterface copyInto(NodeInterface $referenceNode, string $nodeName)

Copies this node to below the given node. The new node will be added behind any existing sub nodes of the given node.

Parameters

NodeInterface $referenceNode
string $nodeName

Return Value

NodeInterface

The copied node

Exceptions

NodeExistsException

NodeData getNodeData()

internal  This is not meant to be used in userland code
 

Return the NodeData representation of the node.

Return Value

NodeData

Context getContext()

internal  This method is not meant to be called in userland code
 

Return the context of the node

Return Value

Context

array getDimensions()

Return the assigned content dimensions of the node.

Return Value

array

An array of dimensions to array of dimension values

NodeInterface createVariantForContext(Context $context)

Given a context a new node is returned that is like this node, but lives in the new context.

Parameters

Context $context

Return Value

NodeInterface

bool isAutoCreated() deprecated

deprecated with version 4.3. This information should not be required usually. Otherwise it can be determined via: if (array_key_exists((string)$node->getNodeName(), $parent->getNodeType()->getAutoCreatedChildNodes()))

Determine if this node is configured as auto-created childNode of the parent node. If that is the case, it should not be deleted.

Return Value

bool

true if this node is auto-created by the parent.

NodeInterface[] getOtherNodeVariants()

Get other variants of this node (with different dimension values)

A variant of a node can have different dimension values and path (for non-aggregate nodes). The resulting node instances might belong to a different context.

Return Value

NodeInterface[]

All node variants of this node (excluding the current node)