neos / contentrepository-development-collection

Work in Progress on the Event Sourced Content Repository as installable set of packages
4 stars 9 forks source link

Node Creation Handlers need to be applied before CreateNodeAggregateWithNode is submitted #139

Closed bwaidelich closed 4 years ago

bwaidelich commented 4 years ago

Currently Node Creation Handlers are applied at the end of AbstractCreate::createNode() when the command has been written (and projected) already.

It is important that the creation handlers can hook into the creation process though in order to be able to enforce domain specific invariants (for example: document nodes need to have a uriPathSegment property set).

Suggestion

in AbstractCreate::createNode() change:

$command = new CreateNodeAggregateWithNode(...);

$this->nodeAggregateCommandHandler->handleCreateNodeAggregateWithNode($command)->blockUntilProjectionsAreUpToDate();

$newlyCreatedNode = $parentNode->findNamedChildNode($nodeName);
$this->applyNodeCreationHandlers($newlyCreatedNode);
    // ...

to:

$command = new CreateNodeAggregateWithNode(...);

$command = $this->applyNodeCreationHandlers($command, $nodeTypeName);

$this->nodeAggregateCommandHandler->handleCreateNodeAggregateWithNode($command)->blockUntilProjectionsAreUpToDate();

$newlyCreatedNode = $parentNode->findNamedChildNode($nodeName);
    // ...