Neos\Neos\Service\Controller\NodeController::createAction PHP Method

createAction() public method

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.
public createAction ( Node $referenceNode, array $nodeData, string $position ) : void
$referenceNode Neos\ContentRepository\Domain\Model\Node
$nodeData array
$position string where the node should be added (allowed: before, into, after)
return void
    public function createAction(Node $referenceNode, array $nodeData, $position)
    {
        $newNode = $this->nodeOperations->create($referenceNode, $nodeData, $position);
        if ($this->request->getHttpRequest()->isMethodSafe() === false) {
            $this->persistenceManager->persistAll();
        }
        $nextUri = $this->uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(true)->uriFor('show', array('node' => $newNode), 'Frontend\\Node', 'Neos.Neos');
        $this->view->assign('value', array('data' => array('nextUri' => $nextUri), 'success' => true));
    }