NodeData
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 | ||
$hidden | If this node is hidden, it is not shown in a public place |
from AbstractNodeData | |
$hiddenBeforeDateTime | |||
$hiddenAfterDateTime | |||
$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
Constructs this node data container
Make sure the properties are always an array.
Sets the specified property.
Checks if a property value contains an entity and persists it.
If this node has a property with the given name.
Sets a content object for this node.
Sets the date and time when this node becomes potentially visible.
Returns the date and time before which this node will be automatically hidden.
Sets the date and time when this node should be automatically hidden
Returns the date and time after which this node will be automatically hidden.
Sets if this node should be hidden in indexes, such as a site navigation.
Sets the roles which are required to access this node
Adds this node to the Node Repository or updates it if it has been added earlier
Updates the attached content object
Returns the workspace this node is contained in
Returns the name of this node
Sets the absolute path of this node
Returns the path of this node
Returns the absolute path of this node with additional context information (such as the workspace name).
Returns the level at which this node is located.
Returns the identifier of this node.
Sets the index of this node
Returns the index of this node which determines the order among siblings with the same parent node.
Returns the parent node path
Creates, adds and returns a child node of this node. Also sets default properties and creates default subnodes.
Creates, adds and returns a child node of this node, without setting default properties or creating subnodes.
Creates and persists a node from the given $nodeTemplate as child node
Change the identifier of this node data
Returns all direct child node data of this node data with reducing the result by dimensionHash only
Returns the number of child nodes a similar getChildNodes() call would return.
Removes this node and all its child nodes. This is an alias for setRemoved(true)
Enables using the remove method when only setters are available
If this node is a removed node.
Tells if this node is "visible".
Tells if this node may be accessed according to the current security context.
Tells if a node, in general, has access restrictions, independent of the current security context.
Internal use, do not retrieve collection directly
Internal use, do not manipulate collection directly
Internal method used in setDimensions to reuse dimension objects with the same name/value pair.
No description
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.
Returns the dimensions and their values.
Build a cached array of dimension values and a hash to search for it.
Get a unique string for all dimension values
Checks if this instance matches the given workspace and dimensions.
Check if this NodeData object is a purely internal technical object (like a shadow node).
Find an existing shadow node data on the given path for the current node data of the node (used by setPath)
Create a shadow NodeData at the given path with the same workspace and dimensions as this
Materializes the original node data (of a different workspace) into the current workspace, excluding content dimensions
Calculates the hash corresponding to the path of this instance.
Calculates the hash corresponding to the dimensions and their values for this instance.
Create a fresh collection instance and clone dimensions
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.
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.
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.
protected
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.
If the node has a content object attached, the property will be checked there.
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.
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.
array
getProperties()
Returns all properties of this node.
If the node has a content object attached, the properties will be fetched there.
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.
NodeType
getNodeType()
Returns the node type of this node.
DateTime
getCreationDateTime()
No description
DateTime
getLastModificationDateTime()
No description
DateTimeInterface
getLastPublicationDateTime()
No description
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.
DateTimeInterface
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
DateTimeInterface
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
protected void
addOrUpdate(NodeData $nodeData = null)
Adds this node to the Node Repository or updates it if it has been added earlier
protected void
updateContentObject(object $contentObject)
Updates the attached content object
Workspace
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
Example: /sites/mysitecom/homepage/about
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
int
getDepth()
Returns the level at which this node is located.
Counting starts with 0 for "/", 1 for "/foo", 2 for "/foo/bar" etc.
void
setWorkspace(Workspace $workspace = null)
Sets the workspace of this node.
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.
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.
NodeData
getParent()
Returns the parent node of this node
string
getParentPath()
Returns the parent node path
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.
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.
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
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).
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.
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".
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.
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.
NodeDimension[]
getDimensions()
Internal use, do not retrieve collection directly
void
setDimensions(array $dimensionsToBeSet)
Internal use, do not manipulate collection directly
protected NodeDimension|null
findExistingDimensionMatching(NodeDimension $dimensionToBeSet)
Internal method used in setDimensions to reuse dimension objects with the same name/value pair.
NodeData
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.
protected 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
Internal method
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).
An internal NodeData should never produce a Node object.
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.
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)
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.
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.
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
protected void
calculatePathHash()
Calculates the hash corresponding to the path of this instance.
protected 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
protected void
emitNodePathChanged(NodeData $nodeData)
Signals that a node has changed its path.