class NodeController extends AbstractServiceController (View source)

Service Controller for managing Nodes

Note: This controller should be, step-by-step, transformed into a clean REST controller (see NEOS-190 and NEOS-199). Since this is a rather big endeavor, we slice the elephant and move methods in a clean way from here to the new NodesController (\Neos\Neos\Controller\Service\NodesController)

Traits

A trait to add backend translation based on the backend users settings

Properties

protected Service $_localizationService from  BackendUserTranslationTrait
protected UserService $_userService from  BackendUserTranslationTrait
protected array $supportedMediaTypes
protected ThrowableStorageInterface $throwableStorage2

Cant be named here $throwableStorage see https://github.com/neos/neos-development-collection/issues/3858

from  AbstractServiceController
protected NodeView $view
protected array $viewFormatToObjectNameMap
protected NodeTypeManager $nodeTypeManager
protected NodeSearchServiceInterface $nodeSearchService
protected NodeFactory $nodeFactory
protected ContextFactoryInterface $contextFactory
protected NodeDataRepository $nodeDataRepository
protected NodeOperations $nodeOperations
protected DomainRepository $domainRepository

Methods

void
initializeObject()

Set the locale according to the user settings

void
errorAction()

A preliminary error action for handling validation errors

void
processRequest(ActionRequest $request, ActionResponse $response)

Catch exceptions while processing an exception and respond to JSON format TODO: This is an explicit exception handling that will be replaced by format-enabled exception handlers.

array
convertException(Exception $exception)

No description

void
initializeAction()

Select special error action

void
getChildNodesForTreeAction(Node $node, string $nodeTypeFilter, int $depth, Node $untilNode)

Return child nodes of specified node for usage in a TreeLoader

void
filterChildNodesForTreeAction(Node $node, string $term, string $nodeType)

Return child nodes of specified node for usage in a TreeLoader based on filter

void
createAction(Node $referenceNode, array $nodeData, string $position)

Creates a new node

string
createAndRenderAction(Node $referenceNode, string $fusionPath, array $nodeData, string $position)

Creates a new node and renders the node inside the containing content collection.

void
createNodeForTheTreeAction(Node $referenceNode, array $nodeData, string $position, string $nodeTypeFilter = '')

Creates a new node and returns tree structure

void
moveAction(Node $node, Node $targetNode, string $position)

Move $node before, into or after $targetNode

void
moveAndRenderAction(Node $node, Node $targetNode, string $position, string $fusionPath)

Move the given node before, into or after the target node depending on the given position and renders it's content collection.

void
copyAction(Node $node, Node $targetNode, string $position, string $nodeName = null)

Copy $node before, into or after $targetNode

void
copyAndRenderAction(Node $node, Node $targetNode, string $position, string $fusionPath, string $nodeName = null)

Copies the given node before, into or after the target node depending on the given position and renders it's content collection.

void
updateAction(Node $node)

Updates the specified node.

void
updateAndRenderAction(Node $node, string $fusionPath)

Updates the specified node and renders it's content collection.

void
deleteAction(Node $node)

Deletes the specified node and all of its sub nodes

string
redirectToRenderNode(NodeInterface $node, string $fusionPath)

Takes care of creating a redirect to properly render the collection the given node is in.

array
processNodeForEditorPlugins(NodeInterface $node)

Returns an array with the data needed by for example the frontend editing link plugins to represent the passed Node instance.

createContext(string $workspaceName)

Create a Context for a workspace given by name to be used in this controller.

Details

protected void initializeObject()

Set the locale according to the user settings

Return Value

void

void errorAction()

A preliminary error action for handling validation errors

Return Value

void

Exceptions

StopActionException

void processRequest(ActionRequest $request, ActionResponse $response)

Catch exceptions while processing an exception and respond to JSON format TODO: This is an explicit exception handling that will be replaced by format-enabled exception handlers.

Parameters

ActionRequest $request

The request object

ActionResponse $response

The response, modified by this handler

Return Value

void

Exceptions

StopActionException
Exception

protected array convertException(Exception $exception)

No description

Parameters

Exception $exception

Return Value

array

protected void initializeAction()

Select special error action

Return Value

void

void getChildNodesForTreeAction(Node $node, string $nodeTypeFilter, int $depth, Node $untilNode)

Return child nodes of specified node for usage in a TreeLoader

Parameters

Node $node

The node to find child nodes for

string $nodeTypeFilter

A node type filter

int $depth

levels of childNodes (0 = unlimited)

Node $untilNode

expand the child nodes until $untilNode is reached, independent of $depth

Return Value

void

void filterChildNodesForTreeAction(Node $node, string $term, string $nodeType)

Return child nodes of specified node for usage in a TreeLoader based on filter

Parameters

Node $node

The node to find child nodes for

string $term
string $nodeType

Return Value

void

void createAction(Node $referenceNode, array $nodeData, string $position)

Creates a new node

We need to call persistAll() in order to return the nextUri. We can't persist only the nodes in NodeDataRepository because they might be connected to images / resources which need to be updated at the same time.

Parameters

Node $referenceNode
array $nodeData
string $position

where the node should be added (allowed: before, into, after)

Return Value

void

string createAndRenderAction(Node $referenceNode, string $fusionPath, array $nodeData, string $position)

Creates a new node and renders the node inside the containing content collection.

Parameters

Node $referenceNode
string $fusionPath

The Fusion path of the collection

array $nodeData
string $position

where the node should be added (allowed: before, into, after)

Return Value

string

void createNodeForTheTreeAction(Node $referenceNode, array $nodeData, string $position, string $nodeTypeFilter = '')

Creates a new node and returns tree structure

Parameters

Node $referenceNode
array $nodeData
string $position

where the node should be added, -1 is before, 0 is in, 1 is after

string $nodeTypeFilter

Return Value

void

void moveAction(Node $node, Node $targetNode, string $position)

Move $node before, into or after $targetNode

We need to call persistAll() in order to return the nextUri. We can't persist only the nodes in NodeDataRepository because they might be connected to images / resources which need to be updated at the same time.

Parameters

Node $node

The node to be moved

Node $targetNode

The target node to be moved "to", see $position

string $position

where the node should be added (allowed: before, into, after)

Return Value

void

void moveAndRenderAction(Node $node, Node $targetNode, string $position, string $fusionPath)

Move the given node before, into or after the target node depending on the given position and renders it's content collection.

Parameters

Node $node

The node to be moved

Node $targetNode

The target node to be moved "to", see $position

string $position

Where the node should be added in relation to $targetNode (allowed: before, into, after)

string $fusionPath

The Fusion path of the collection

Return Value

void

void copyAction(Node $node, Node $targetNode, string $position, string $nodeName = null)

Copy $node before, into or after $targetNode

We need to call persistAll() in order to return the nextUri. We can't persist only the nodes in NodeDataRepository because they might be connected to images / resources which need to be updated at the same time.

Parameters

Node $node

The node to be copied

Node $targetNode

The target node to be copied "to", see $position

string $position

Where the node should be added in relation to $targetNode (allowed: before, into, after)

string $nodeName

Optional node name (if empty random node name will be generated)

Return Value

void

Exceptions

NodeException

void copyAndRenderAction(Node $node, Node $targetNode, string $position, string $fusionPath, string $nodeName = null)

Copies the given node before, into or after the target node depending on the given position and renders it's content collection.

Parameters

Node $node

The node to be copied

Node $targetNode

The target node to be copied "to", see $position

string $position

Where the node should be added in relation to $targetNode (allowed: before, into, after)

string $fusionPath

The Fusion path of the collection

string $nodeName

Optional node name (if empty random node name will be generated)

Return Value

void

void updateAction(Node $node)

Updates the specified node.

Returns the following data:

  • the (possibly changed) workspace name of the node
  • the URI of the closest document node. If $node is a document node (f.e. a Page), the own URI is returned. This is important to handle renames of nodes correctly.

Note: We do not call $nodeDataRepository->update() here, as ContentRepository has a stateful API for now. We need to call persistAll() in order to return the nextUri. We can't persist only the nodes in NodeDataRepository because they might be connected to images / resources which need to be updated at the same time.

Parameters

Node $node

The node to be updated

Return Value

void

void updateAndRenderAction(Node $node, string $fusionPath)

Updates the specified node and renders it's content collection.

Parameters

Node $node

The node to be updated

string $fusionPath

The Fusion path of the collection

Return Value

void

void deleteAction(Node $node)

Deletes the specified node and all of its sub nodes

We need to call persistAll() in order to return the nextUri. We can't persist only the nodes in NodeDataRepository because they might be connected to images / resources which need to be removed at the same time.

Parameters

Node $node

Return Value

void

protected string redirectToRenderNode(NodeInterface $node, string $fusionPath)

Takes care of creating a redirect to properly render the collection the given node is in.

Parameters

NodeInterface $node
string $fusionPath

Return Value

string

protected array processNodeForEditorPlugins(NodeInterface $node)

Returns an array with the data needed by for example the frontend editing link plugins to represent the passed Node instance.

Parameters

NodeInterface $node

Return Value

array

protected Context createContext(string $workspaceName)

Create a Context for a workspace given by name to be used in this controller.

Parameters

string $workspaceName

Name of the current workspace

Return Value

Context