class NodeCommandControllerPlugin implements EventDispatchingNodeCommandControllerPluginInterface (View source)

Plugin for the ContentRepository NodeCommandController which provides functionality for creating missing child nodes.

Properties

protected ContextFactoryInterface $contextFactory
protected NodeTypeManager $nodeTypeManager
protected WorkspaceRepository $workspaceRepository
protected NodeFactory $nodeFactory
protected ConsoleOutput deprecated $output
protected NodeDataRepository $nodeDataRepository
protected EntityManagerInterface $entityManager
protected PropertyMapper $propertyMapper
protected array $pluginConfigurations
protected ContentDimensionCombinator $contentDimensionCombinator
protected PersistenceManagerInterface $persistenceManager
protected Closure[] $eventCallbacks

Callbacks to be invoked when an event is triggered

Methods

static string
getSubCommandShortDescription(string $controllerCommandName)

Returns a short description

static string
getSubCommandDescription(string $controllerCommandName)

Returns a piece of description for the specific task the plugin solves for the specified command

void
invokeSubCommand(string $controllerCommandName, ConsoleOutput $output, NodeType $nodeType = null, string $workspaceName = 'live', bool $dryRun = false, bool $cleanup = true, string $skip = null, string $only = null)

A method which runs the task implemented by the plugin for the given command

void
createMissingChildNodes(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Performs checks for missing child nodes according to the node's auto-create configuration and creates them if necessary.

void
createChildNodesByNodeType(NodeType $nodeType, string $workspaceName, bool $dryRun)

Create missing child nodes for the given node type

void
addMissingDefaultValues(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Performs checks for unset properties that has default values and sets them if necessary.

void
addMissingDefaultValuesByNodeType(NodeType $nodeType, string $workspaceName, bool $dryRun)

Adds missing default values for the given node type

void
removeAbstractAndUndefinedNodes(string $workspaceName)

Performs checks for nodes with abstract or undefined node types and removes them if found.

void
removeDisallowedChildNodes(string $workspaceName)

Performs checks for disallowed child nodes according to the node's auto-create configuration and constraints and removes them if found.

void
removeOrphanNodes(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Performs checks for orphan nodes removes them if found.

void
removeUndefinedProperties(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Performs checks for orphan nodes removes them if found.

void
removeBrokenEntityReferences(string $workspaceName)

Remove broken entity references

createContext(string $workspaceName, array $dimensions)

Creates a content context for given workspace

getNodeDataByNodeTypeAndWorkspace(string $nodeType, string $workspaceName)

Retrieves all NodeData objects of a certain node type inside a given workspace.

removeNodeAndChildNodesInWorkspaceByPath(string $nodePath, string $workspaceName)

Removes all nodes with a specific path and their children in the given workspace.

removeNode(string $nodeIdentifier, string $dimensionsHash)

Removes the specified node (exactly that one)

void
removeNodesWithInvalidDimensions(string $workspaceName)

Remove nodes with invalid dimension values

array
collectNodesWithInvalidDimensions(string $workspaceName, array $allowedDimensionCombinations)

Collects all nodes of the given node type which have dimension values not fitting to the current dimension configuration.

void
removeNodesWithInvalidWorkspace()

Remove nodes with invalid workspace

array
collectNodesWithInvalidWorkspace()

Collects all nodes of the given node type which refer to an invalid workspace configuration.

void
fixNodesWithInconsistentIdentifier()

Detect and fix nodes in non-live workspaces whose identifier does not match their corresponding node in the live workspace.

void
reorderChildNodes(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Reorder child nodes according to the current position configuration of child nodes.

void
reorderChildNodesByNodeType(string $workspaceName, bool $dryRun, NodeType $nodeType)

Reorder child nodes for the given node type

void
repairShadowNodes(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Repair nodes whose shadow nodes are missing

array
findMissingShadowNodesInWorkspace(Workspace $workspace, NodeType $nodeType = null)

Collects all nodes with missing shadow nodes

void
on(string $eventIdentifier, Closure $callback)

Attaches a new event handler

void
dispatch(string $eventIdentifier, array ...$eventPayload)

Trigger a custom event

Details

static string getSubCommandShortDescription(string $controllerCommandName)

Returns a short description

Parameters

string $controllerCommandName

Name of the command in question, for example "repair"

Return Value

string

A brief description / summary for the task this plugin is going to do

static string getSubCommandDescription(string $controllerCommandName)

Returns a piece of description for the specific task the plugin solves for the specified command

Parameters

string $controllerCommandName

Name of the command in question, for example "repair"

Return Value

string

A piece of text to be included in the overall description of the node:xy command

void invokeSubCommand(string $controllerCommandName, ConsoleOutput $output, NodeType $nodeType = null, string $workspaceName = 'live', bool $dryRun = false, bool $cleanup = true, string $skip = null, string $only = null)

A method which runs the task implemented by the plugin for the given command

Parameters

string $controllerCommandName

Name of the command in question, for example "repair"

ConsoleOutput $output

An instance of ConsoleOutput which can be used for output or dialogues

NodeType $nodeType

Only handle this node type (if specified)

string $workspaceName

Only handle this workspace (if specified)

bool $dryRun

If true, don't do any changes, just simulate what you would do

bool $cleanup

If false, cleanup tasks are skipped

string $skip

Skip the given check or checks (comma separated)

string $only

Only execute the given check or checks (comma separated)

Return Value

void

protected void createMissingChildNodes(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Performs checks for missing child nodes according to the node's auto-create configuration and creates them if necessary.

Parameters

string $workspaceName

Name of the workspace to consider

bool $dryRun Simulate?
NodeType $nodeType

Only for this node type, if specified

Return Value

void

Exceptions

NodeConfigurationException
NodeTypeNotFoundException

protected void createChildNodesByNodeType(NodeType $nodeType, string $workspaceName, bool $dryRun)

Create missing child nodes for the given node type

Parameters

NodeType $nodeType
string $workspaceName
bool $dryRun

Return Value

void

Exceptions

NodeTypeNotFoundException
NodeConfigurationException

void addMissingDefaultValues(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Performs checks for unset properties that has default values and sets them if necessary.

Parameters

string $workspaceName

Name of the workspace to consider

bool $dryRun Simulate?
NodeType $nodeType

Only for this node type, if specified

Return Value

void

Exceptions

NodeConfigurationException
NodeTypeNotFoundException

void addMissingDefaultValuesByNodeType(NodeType $nodeType, string $workspaceName, bool $dryRun)

Adds missing default values for the given node type

Parameters

NodeType $nodeType
string $workspaceName
bool $dryRun

Return Value

void

Exceptions

NodeConfigurationException
NodeTypeNotFoundException

protected void removeAbstractAndUndefinedNodes(string $workspaceName)

Performs checks for nodes with abstract or undefined node types and removes them if found.

Parameters

string $workspaceName

Return Value

void

protected void removeDisallowedChildNodes(string $workspaceName)

Performs checks for disallowed child nodes according to the node's auto-create configuration and constraints and removes them if found.

Parameters

string $workspaceName

Return Value

void

protected void removeOrphanNodes(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Performs checks for orphan nodes removes them if found.

Parameters

string $workspaceName
bool $dryRun (unused)
NodeType $nodeType

Only for this node type, if specified

Return Value

void

void removeUndefinedProperties(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Performs checks for orphan nodes removes them if found.

Parameters

string $workspaceName
bool $dryRun (unused)
NodeType $nodeType

Only for this node type, if specified

Return Value

void

Exceptions

NodeConfigurationException

void removeBrokenEntityReferences(string $workspaceName)

Remove broken entity references

This removes references from nodes to entities which don't exist anymore.

Parameters

string $workspaceName

Return Value

void

Exceptions

NodeException
Exception
Exception

protected Context createContext(string $workspaceName, array $dimensions)

Creates a content context for given workspace

Parameters

string $workspaceName
array $dimensions

Return Value

Context

protected NodeData[] getNodeDataByNodeTypeAndWorkspace(string $nodeType, string $workspaceName)

Retrieves all NodeData objects of a certain node type inside a given workspace.

Shadow nodes are excluded, because they will be published when publishing the moved node.

Parameters

string $nodeType
string $workspaceName

Return Value

NodeData[]

protected removeNodeAndChildNodesInWorkspaceByPath(string $nodePath, string $workspaceName)

Removes all nodes with a specific path and their children in the given workspace.

Parameters

string $nodePath
string $workspaceName

protected removeNode(string $nodeIdentifier, string $dimensionsHash)

Removes the specified node (exactly that one)

Parameters

string $nodeIdentifier
string $dimensionsHash

void removeNodesWithInvalidDimensions(string $workspaceName)

Remove nodes with invalid dimension values

This removes nodes which have dimension values not fitting to the current dimension configuration

Parameters

string $workspaceName

Name of the workspace to consider

Return Value

void

protected array collectNodesWithInvalidDimensions(string $workspaceName, array $allowedDimensionCombinations)

Collects all nodes of the given node type which have dimension values not fitting to the current dimension configuration.

Parameters

string $workspaceName
array $allowedDimensionCombinations

Return Value

array

void removeNodesWithInvalidWorkspace()

Remove nodes with invalid workspace

This removes nodes which refer to a workspace which does not exist.

Return Value

void

protected array collectNodesWithInvalidWorkspace()

Collects all nodes of the given node type which refer to an invalid workspace configuration.

Note: due to the foreign key constraints in the database, there actually never should be any node with n.workspace of a non-existing workspace because if that workspace does not exist anymore, the value would turn NULL. But the query covers this nevertheless. Better safe than sorry.

Return Value

array

void fixNodesWithInconsistentIdentifier()

Detect and fix nodes in non-live workspaces whose identifier does not match their corresponding node in the live workspace.

Return Value

void

protected void reorderChildNodes(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Reorder child nodes according to the current position configuration of child nodes.

Parameters

string $workspaceName

Name of the workspace to consider

bool $dryRun Simulate?
NodeType $nodeType

Only for this node type, if specified

Return Value

void

Exceptions

NodeConfigurationException
NodeTypeNotFoundException

protected void reorderChildNodesByNodeType(string $workspaceName, bool $dryRun, NodeType $nodeType)

Reorder child nodes for the given node type

Parameters

string $workspaceName
bool $dryRun (unused)
NodeType $nodeType

Return Value

void

Exceptions

NodeTypeNotFoundException
NodeConfigurationException

protected void repairShadowNodes(string $workspaceName, bool $dryRun, NodeType $nodeType = null)

Repair nodes whose shadow nodes are missing

This check searches for nodes which have a corresponding node in one of the base workspaces, have different node paths, but don't have a corresponding shadow node with a "movedto" value.

Parameters

string $workspaceName

Currently ignored

bool $dryRun (unused)
NodeType $nodeType

This argument will be ignored

Return Value

void

protected array findMissingShadowNodesInWorkspace(Workspace $workspace, NodeType $nodeType = null)

Collects all nodes with missing shadow nodes

Parameters

Workspace $workspace
NodeType $nodeType

Return Value

array

in the form [['nodeData' => , 'shadowPath' => ''], ...]

void on(string $eventIdentifier, Closure $callback)

Attaches a new event handler

Parameters

string $eventIdentifier

one of the EVENT_* constants

Closure $callback

a closure to be invoked when the corresponding event was triggered

Return Value

void

protected void dispatch(string $eventIdentifier, array ...$eventPayload)

Trigger a custom event

Parameters

string $eventIdentifier

one of the EVENT_* constants

array ...$eventPayload

optional arguments to be passed to the handler closure

Return Value

void