class NodeData extends AbstractNodeData (View source)

The node data inside the content repository. This is only a data container that could be exchanged in the future.

NOTE: This is internal only and should not be used or extended by userland code.

Properties

protected array $properties

Properties of this Node

from  AbstractNodeData
protected ContentObjectProxy $contentObjectProxy

Optional proxy for a content object which acts as an alternative property container

protected string $nodeType

The name of the node type of this node

from  AbstractNodeData
protected DateTimeInterface $creationDateTime from  AbstractNodeData
protected DateTime $lastModificationDateTime
protected DateTime $lastPublicationDateTime
protected bool $hidden

If this node is hidden, it is not shown in a public place

from  AbstractNodeData
protected DateTime $hiddenBeforeDateTime
protected DateTime $hiddenAfterDateTime
protected bool $hiddenInIndex

If this node should be hidden in indexes, such as a website navigation

from  AbstractNodeData
protected string[] $accessRoles

List of role names which are required to access this node at all

from  AbstractNodeData
protected NodeDataRepository $nodeDataRepository from  AbstractNodeData
protected PersistenceManagerInterface $persistenceManager from  AbstractNodeData
protected NodeTypeManager $nodeTypeManager from  AbstractNodeData
protected int $version

Auto-incrementing version of this node data, used for optimistic locking

protected string $pathHash

MD5 hash of the path This property is needed for the unique index over path & workspace (for which the path property is too large).

protected string $path

Absolute path of this node

protected string $parentPathHash

MD5 hash of the parent path This property is needed to speed up lookup by parent path.

protected string $parentPath

Absolute path of the parent path

protected Workspace $workspace

Workspace this node is contained in

protected string $identifier

Identifier of this node which is unique within its workspace

protected int $index

Index within the nodes with the same parent

protected int $depth

Level number within the global node tree

protected string $name

Node name, derived from its node path

protected bool $removed

If this is a removed node. This flag can and is only used in workspaces which do have a base workspace. In a bottom level workspace nodes are really removed, in other workspaces, removal is realized by this flag.

protected NodeDimension> $dimensions
protected string $dimensionsHash

MD5 hash of the content dimensions The hash is generated in buildDimensionValues().

protected array $dimensionValues
protected NodeData $movedTo

If a node data is moved a "shadow" node data is inserted that references the new node data

protected Context $securityContext
protected NodeServiceInterface $nodeService

Methods

__construct(string $path, Workspace $workspace, string $identifier = null, array $dimensions = null)

Constructs this node data container

void
ensurePropertiesIsNeverNull()

Make sure the properties are always an array.

void
setProperty(string $propertyName, mixed $value)

Sets the specified property.

persistRelatedEntities(mixed $value)

Checks if a property value contains an entity and persists it.

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.

array
getProperties()

Returns all properties of this node.

array
getPropertyNames()

Returns the names of all properties of this node.

void
setContentObject(object $contentObject)

Sets a content object for this node.

object
getContentObject()

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

void
unsetContentObject()

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
setLastPublicationDateTime(DateTimeInterface $lastPublicationDateTime = null)

No description

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)

Sets the roles which are required to access this node

array
getAccessRoles()

Returns the names of defined access roles

void
addOrUpdate(NodeData $nodeData = null)

Adds this node to the Node Repository or updates it if it has been added earlier

void
updateContentObject(object $contentObject)

Updates the attached content object

getWorkspace()

Returns the workspace this node is contained in

string
getName()

Returns the name of this node

void
setPath(string $path, bool $recursive = true)

Sets the absolute path of this node

string
getPath()

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()

Returns the level at which this node is located.

void
setWorkspace(Workspace $workspace = null)

Sets the workspace of this node.

string
getIdentifier()

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()

Returns the parent node of this node

string
getParentPath()

Returns the parent node path

createNodeData(string $name, NodeType $nodeType = null, string $identifier = null, Workspace $workspace = null, array $dimensions = null)

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

createSingleNodeData(string $name, NodeType $nodeType = null, string $identifier = null, Workspace $workspace = null, array $dimensions = null)

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

createNodeDataFromTemplate(NodeTemplate $nodeTemplate, string $nodeName = null, Workspace $workspace = null, array $dimensions = null)

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

void
setIdentifier(string $identifier)

Change the identifier of this node data

getChildNodeData()

Returns all direct child node data of this node data with reducing the result by dimensionHash only

int
getNumberOfChildNodes(string $nodeTypeFilter = null, Workspace $workspace, array $dimensions)

Returns the number of child nodes a similar getChildNodes() call would return.

void
remove()

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

void
setRemoved(bool $removed)

Enables using the remove method when only setters are available

bool
isRemoved()

If this node is a removed node.

bool
isVisible()

Tells if this node is "visible".

bool
isAccessible()

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

bool
hasAccessRestrictions()

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

getDimensions()

Internal use, do not retrieve collection directly

void
setDimensions(array $dimensionsToBeSet)

Internal use, do not manipulate collection directly

findExistingDimensionMatching(NodeDimension $dimensionToBeSet)

Internal method used in setDimensions to reuse dimension objects with the same name/value pair.

getMovedTo()

No description

void
setMovedTo(NodeData $nodeData = null)

No description

void
similarize(AbstractNodeData $sourceNode, bool $isCopy = false)

Make the node "similar" to the given source node. That means,

  • all properties
  • index
  • node type
  • content object will be set to the same values as in the source node.

array
getDimensionValues()

Returns the dimensions and their values.

void
buildDimensionValues()

Build a cached array of dimension values and a hash to search for it.

string
getDimensionsHash()

Get a unique string for all dimension values

bool
matchesWorkspaceAndDimensions(Workspace $workspace, array $dimensions = null)

Checks if this instance matches the given workspace and dimensions.

bool
isInternal()

Check if this NodeData object is a purely internal technical object (like a shadow node).

move(string $targetPath, Workspace $targetWorkspace)

Move this NodeData to the given path and workspace.

NodeData|null
getExistingShadowNodeDataInExactWorkspace(string $path, Workspace $workspace, array $dimensionValues)

Find an existing shadow node data on the given path for the current node data of the node (used by setPath)

createShadow(string $path)

Create a shadow NodeData at the given path with the same workspace and dimensions as this

void
setAsShadowOf(NodeData $nodeData = null)

This becomes a shdow of the given NodeData object.

materializeToWorkspace(Workspace $workspace)

Materializes the original node data (of a different workspace) into the current workspace, excluding content dimensions

void
calculatePathHash()

Calculates the hash corresponding to the path of this instance.

void
calculateParentPathHash()

Calculates the hash corresponding to the dimensions and their values for this instance.

void
__clone()

Create a fresh collection instance and clone dimensions

void
emitNodePathChanged(NodeData $nodeData)

Signals that a node has changed its path.

Details

__construct(string $path, Workspace $workspace, string $identifier = null, array $dimensions = null)

Constructs this node data container

Creating new nodes by instantiating NodeData is not part of the public API! The content repository needs to properly integrate new nodes into the node tree and therefore you must use createNode() or createNodeFromTemplate() in a Node object which will internally create a NodeData object.

Parameters

string $path

Absolute path of this node

Workspace $workspace

The workspace this node will be contained in

string $identifier

The node identifier (not the persistence object identifier!). Specifying this only makes sense while creating corresponding nodes

array $dimensions

An array of dimension name to dimension values

void ensurePropertiesIsNeverNull()

Make sure the properties are always an array.

If the JSON in the DB is corrupted, decoding it can fail, leading to a null value. This may lead to errors later, when the value is used with functions that expect an array.

Return Value

void

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

protected persistRelatedEntities(mixed $value)

Checks if a property value contains an entity and persists it.

Parameters

mixed $value

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

array getProperties()

Returns all properties of this node.

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

Return Value

array

Property values, indexed by their name

array getPropertyNames()

Returns the names of all properties of this node.

Return Value

array

Property names

void setContentObject(object $contentObject)

Sets a content object for this node.

Parameters

object $contentObject

The content object

Return Value

void

Exceptions

InvalidArgumentException

object getContentObject()

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

Return Value

object

The content object or NULL if none was set

void unsetContentObject()

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

Exceptions

NodeTypeNotFoundException

DateTime getCreationDateTime()

No description

Return Value

DateTime

DateTime getLastModificationDateTime()

No description

Return Value

DateTime

DateTimeInterface getLastPublicationDateTime()

No description

Return Value

DateTimeInterface

void setLastPublicationDateTime(DateTimeInterface $lastPublicationDateTime = null)

No description

Parameters

DateTimeInterface $lastPublicationDateTime

Return Value

void

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 getHiddenBeforeDateTime()

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

Return Value

DateTimeInterface

Date before this node will be hidden or NULL if no such time was 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 or NULL if no such time was set

Return Value

void

DateTimeInterface getHiddenAfterDateTime()

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

Return Value

DateTimeInterface

Date after which this node will be hidden

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)

Sets the roles which are required to access this node

Parameters

array $accessRoles

Return Value

void

Exceptions

InvalidArgumentException

array getAccessRoles()

Returns the names of defined access roles

Return Value

array

protected void addOrUpdate(NodeData $nodeData = null)

Adds this node to the Node Repository or updates it if it has been added earlier

Parameters

NodeData $nodeData

Other NodeData object to addOrUpdate

Return Value

void

Exceptions

IllegalObjectTypeException

protected void updateContentObject(object $contentObject)

Updates the attached content object

Parameters

object $contentObject

Return Value

void

Workspace getWorkspace()

Returns the workspace this node is contained in

Return Value

Workspace

string getName()

Returns the name of this node

Return Value

string

void setPath(string $path, bool $recursive = true)

Sets the absolute path of this node

Parameters

string $path
bool $recursive

Return Value

void

Exceptions

InvalidArgumentException

string getPath()

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

Return Value

string

Node path with context information

int getDepth()

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 = null)

Sets the workspace of this node.

Parameters

Workspace $workspace

Return Value

void

string getIdentifier()

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

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

NodeData getParent()

Returns the parent node of this node

Return Value

NodeData

The parent node or NULL if this is the root node

string getParentPath()

Returns the parent node path

Return Value

string

Absolute node path of the parent node

NodeData createNodeData(string $name, NodeType $nodeType = null, string $identifier = null, Workspace $workspace = null, array $dimensions = 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(!)

Workspace $workspace
array $dimensions

Return Value

NodeData

NodeData createSingleNodeData(string $name, NodeType $nodeType = null, string $identifier = null, Workspace $workspace = null, array $dimensions = null)

Creates, adds and returns a child node of this node, without setting default properties or creating 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(!)

Workspace $workspace
array $dimensions

An array of dimension name to dimension values

Return Value

NodeData

Exceptions

NodeExistsException
InvalidArgumentException

NodeData createNodeDataFromTemplate(NodeTemplate $nodeTemplate, string $nodeName = null, Workspace $workspace = null, array $dimensions = 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.

Workspace $workspace
array $dimensions

Return Value

NodeData

the freshly generated node

void setIdentifier(string $identifier)

Change the identifier of this node data

NOTE: This is only used for some very rare cases (to replace existing instances when moving).

Parameters

string $identifier

Return Value

void

protected NodeData[] getChildNodeData()

Returns all direct child node data of this node data with reducing the result by dimensionHash only

Only used internally for setting the path of all child nodes.

Return Value

NodeData[]

int getNumberOfChildNodes(string $nodeTypeFilter = null, Workspace $workspace, array $dimensions)

Returns the number of child nodes a similar getChildNodes() call would return.

Parameters

string $nodeTypeFilter

If specified, only nodes with that node type are considered

Workspace $workspace
array $dimensions

Return Value

int

The number of child nodes

void remove()

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

Return Value

void

void setRemoved(bool $removed)

Enables using the remove method when only setters are available

Parameters

bool $removed

If true, this node and it's child nodes will be removed. This can handle false as well.

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. The fact that a node is "visible" does not imply that it can / may be shown to the user. Further modifiers such as isAccessible() need to be evaluated.

Return Value

bool

bool isAccessible()

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

Return Value

bool

bool hasAccessRestrictions()

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

Return Value

bool

NodeDimension[] getDimensions()

Internal use, do not retrieve collection directly

Return Value

NodeDimension[]

void setDimensions(array $dimensionsToBeSet)

Internal use, do not manipulate collection directly

Parameters

array $dimensionsToBeSet

Return Value

void

protected NodeDimension|null findExistingDimensionMatching(NodeDimension $dimensionToBeSet)

Internal method used in setDimensions to reuse dimension objects with the same name/value pair.

Parameters

NodeDimension $dimensionToBeSet

Return Value

NodeDimension|null

See also

setDimensions

NodeData getMovedTo()

No description

Return Value

NodeData

void setMovedTo(NodeData $nodeData = null)

No description

Parameters

NodeData $nodeData

Return Value

void

void similarize(AbstractNodeData $sourceNode, bool $isCopy = false)

Make the node "similar" to the given source node. That means,

  • all properties
  • index
  • node type
  • content object will be set to the same values as in the source node.

Parameters

AbstractNodeData $sourceNode
bool $isCopy

Return Value

void

array getDimensionValues()

Returns the dimensions and their values.

Return Value

array

protected void buildDimensionValues()

Build a cached array of dimension values and a hash to search for it.

Return Value

void

string getDimensionsHash()

Get a unique string for all dimension values

Internal method

Return Value

string

bool matchesWorkspaceAndDimensions(Workspace $workspace, array $dimensions = null)

Checks if this instance matches the given workspace and dimensions.

Parameters

Workspace $workspace
array $dimensions

Return Value

bool

bool isInternal()

Check if this NodeData object is a purely internal technical object (like a shadow node).

An internal NodeData should never produce a Node object.

Return Value

bool

NodeData move(string $targetPath, Workspace $targetWorkspace)

Move this NodeData to the given path and workspace.

Basically 4 scenarios have to be covered here, depending on:

  • Does the NodeData have to be materialized (adapted to the workspace or target dimension)?
  • Does a shadow node exist on the target path?

Because unique key constraints and Doctrine ORM don't support arbitrary removal and update combinations, existing NodeData instances are re-used and the metadata and content is swapped around.

Parameters

string $targetPath
Workspace $targetWorkspace

Return Value

NodeData

If a shadow node was created this is the new NodeData object after the move.

protected NodeData|null getExistingShadowNodeDataInExactWorkspace(string $path, Workspace $workspace, array $dimensionValues)

Find an existing shadow node data on the given path for the current node data of the node (used by setPath)

Parameters

string $path

The (new) path of the node data

Workspace $workspace

The workspace. Only shadow node data object with exactly this workspace will be considered

array $dimensionValues

Dimension values which must match with an existing node data object

Return Value

NodeData|null

NodeData createShadow(string $path)

Create a shadow NodeData at the given path with the same workspace and dimensions as this

Note: The constructor will already add the new object to the repository Internal method, do not use outside of the content repository.

Parameters

string $path

The (original) path for the node data

Return Value

NodeData

protected void setAsShadowOf(NodeData $nodeData = null)

This becomes a shdow of the given NodeData object.

If NULL or no argument is given then movedTo is nulled and removed is set to false effectively turning this into a normal NodeData.

Parameters

NodeData $nodeData

Return Value

void

protected NodeData materializeToWorkspace(Workspace $workspace)

Materializes the original node data (of a different workspace) into the current workspace, excluding content dimensions

This is only used in setPath for now

Parameters

Workspace $workspace

Return Value

NodeData

protected void calculatePathHash()

Calculates the hash corresponding to the path of this instance.

Return Value

void

protected void calculateParentPathHash()

Calculates the hash corresponding to the dimensions and their values for this instance.

Return Value

void

void __clone()

Create a fresh collection instance and clone dimensions

Return Value

void

protected void emitNodePathChanged(NodeData $nodeData)

Signals that a node has changed its path.

Parameters

NodeData $nodeData

the node data instance that has been changed

Return Value

void