class NodeService implements NodeServiceInterface (View source)

Provide method to manage node

Properties

protected NodeTypeManager $nodeTypeManager
protected NodeDataRepository $nodeDataRepository
protected ContextFactory $contextFactory

Methods

void
setDefaultValues(NodeInterface $node)

Sets default node property values on the given node.

void
createChildNodes(NodeInterface $node)

Creates missing child nodes for the given node.

void
cleanUpAutoCreatedChildNodes(NodeInterface $node, NodeType $oldNodeType)

Removes all auto created child nodes that existed in the previous nodeType.

void
cleanUpProperties(NodeInterface $node)

Remove all properties not configured in the current Node Type.

bool
isNodeOfType(NodeInterface $node, NodeType $nodeType)

No description

bool
nodePathExistsInAnyContext(string $nodePath)

Checks if the given node path exists in any possible context already.

bool
nodePathAvailableForNode(string $nodePath, NodeInterface $node)

Checks if the given node path can be used for the given node.

string
normalizePath(string $path, string $referencePath = null)

Normalizes the given node path to a reference path and returns an absolute path.

string
generateUniqueNodeName(string $parentPath, string $idealNodeName = null)

Generate a node name, optionally based on a suggested "ideal" name

string
generatePossibleNodeName(string $idealNodeName = null)

Generate possible node name. When an idealNodeName is given then this is put into a valid format for a node name, otherwise a random node name in the form "node-alphanumeric" is generated.

Details

void setDefaultValues(NodeInterface $node)

Sets default node property values on the given node.

Parameters

NodeInterface $node

Return Value

void

void createChildNodes(NodeInterface $node)

Creates missing child nodes for the given node.

Parameters

NodeInterface $node

Return Value

void

void cleanUpAutoCreatedChildNodes(NodeInterface $node, NodeType $oldNodeType)

Removes all auto created child nodes that existed in the previous nodeType.

Parameters

NodeInterface $node
NodeType $oldNodeType

Return Value

void

void cleanUpProperties(NodeInterface $node)

Remove all properties not configured in the current Node Type.

This will not do anything on Nodes marked as removed as those could be queued up for deletion which contradicts updates (that would be necessary to remove the properties).

Parameters

NodeInterface $node

Return Value

void

bool isNodeOfType(NodeInterface $node, NodeType $nodeType)

No description

Parameters

NodeInterface $node
NodeType $nodeType

Return Value

bool

bool nodePathExistsInAnyContext(string $nodePath)

Checks if the given node path exists in any possible context already.

Parameters

string $nodePath

Return Value

bool

bool nodePathAvailableForNode(string $nodePath, NodeInterface $node)

Checks if the given node path can be used for the given node.

Parameters

string $nodePath
NodeInterface $node

Return Value

bool

string normalizePath(string $path, string $referencePath = null)

Normalizes the given node path to a reference path and returns an absolute path.

Parameters

string $path

The non-normalized path

string $referencePath

a reference path in case the given path is relative.

Return Value

string

The normalized absolute path

Exceptions

InvalidArgumentException

string generateUniqueNodeName(string $parentPath, string $idealNodeName = null)

Generate a node name, optionally based on a suggested "ideal" name

Parameters

string $parentPath
string $idealNodeName

Can be any string, doesn't need to be a valid node name.

Return Value

string

valid node name that is possible as child of the given $parentNode

protected string generatePossibleNodeName(string $idealNodeName = null)

Generate possible node name. When an idealNodeName is given then this is put into a valid format for a node name, otherwise a random node name in the form "node-alphanumeric" is generated.

Parameters

string $idealNodeName

Return Value

string