Neos.Neos/Classes/Service/Controller/NodeController.php
public function deleteAction(Node $node)
    {
        if ($this->request->getHttpRequest()->isMethodSafe() === false) {
            $this->persistenceManager->persistAll();
        }

        $q = new FlowQuery([$node]);
        $node->remove();
        $closestDocumentNode = $q->closest('[instanceof Neos.Neos:Document]')->get(0);
        $nextUri = $this->uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(true)->uriFor('show', ['node' => $closestDocumentNode], 'Frontend\Node', 'Neos.Neos');

        $this->view->assign('value', ['data' => ['nextUri' => $nextUri], 'success' => true]);
    }
public function deleteAction(Node $node)
    {
        if ($this->request->getHttpRequest()->isMethodSafe() === false) {
            $this->persistenceManager->persistAll();
        }

        $q = new FlowQuery([$node]);
        $node->remove();
        $closestDocumentNode = $q->closest('[instanceof Neos.Neos:Document]')->get(0);
        $nextUri = $this->uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(true)->uriFor('show', ['node' => $closestDocumentNode], 'Frontend\Node', 'Neos.Neos');

        $this->view->assign('value', ['data' => ['nextUri' => $nextUri], 'success' => true]);
    }
public function deleteAction ( Node $ node ) { if ( $ this -> request -> getHttpRequest ( ) -> isMethodSafe ( ) === false ) { $ this -> persistenceManager -> persistAll ( ) ; } $ q = new FlowQuery ( [ $ node ] ) ; $ node -> remove ( ) ; $ closestDocumentNode = $ q -> closest ( '[instanceof Neos.Neos:Document]' ) -> get ( 0 ) ; $ nextUri = $ this -> uriBuilder -> reset ( ) -> setFormat ( 'html' ) -> setCreateAbsoluteUri ( true ) -> uriFor ( 'show' , [ 'node' => $ closestDocumentNode ] , 'Frontend\Node' , 'Neos.Neos' ) ; $ this -> view -> assign ( 'value' , [ 'data' => [ 'nextUri' => $ nextUri ] , 'success' => true ] ) ; }
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.

@param Node $node
@return void
Deletes the specified node and all of its sub nodes