src/Sulu/Component/Content/Document/Subscriber/RouteSubscriber.php
public function handleSetNodeOnPersist(PersistEvent $event)
    {
        $document = $event->getDocument();
        $options = $event->getOptions();
        if (!$document instanceof RouteBehavior || !array_key_exists('path', $options)) {
            return;
        }

        $parentPath = PathHelper::getParentPath($options['path']);
        $parentNode = $this->nodeManager->createPath($parentPath);

        $nodeName = PathHelper::getNodeName($options['path']);
        if (!$parentNode->hasNode($nodeName)) {
            return;
        }

        $node = $parentNode->getNode($nodeName);
        if ($node->hasProperty(self::NODE_HISTORY_FIELD)) {
            return;
        }

        $event->setNode($node);
        $event->setParentNode($parentNode);
    }
public function handleSetNodeOnPersist(PersistEvent $event)
    {
        $document = $event->getDocument();
        $options = $event->getOptions();
        if (!$document instanceof RouteBehavior || !array_key_exists('path', $options)) {
            return;
        }

        $parentPath = PathHelper::getParentPath($options['path']);
        $parentNode = $this->nodeManager->createPath($parentPath);

        $nodeName = PathHelper::getNodeName($options['path']);
        if (!$parentNode->hasNode($nodeName)) {
            return;
        }

        $node = $parentNode->getNode($nodeName);
        if ($node->hasProperty(self::NODE_HISTORY_FIELD)) {
            return;
        }

        $event->setNode($node);
        $event->setParentNode($parentNode);
    }
public function handleSetNodeOnPersist ( PersistEvent $ event ) { $ document = $ event -> getDocument ( ) ; $ options = $ event -> getOptions ( ) ; if ( ! $ document instanceof RouteBehavior || ! array_key_exists ( 'path' , $ options ) ) { return ; } $ parentPath = PathHelper :: getParentPath ( $ options [ 'path' ] ) ; $ parentNode = $ this -> nodeManager -> createPath ( $ parentPath ) ; $ nodeName = PathHelper :: getNodeName ( $ options [ 'path' ] ) ; if ( ! $ parentNode -> hasNode ( $ nodeName ) ) { return ; } $ node = $ parentNode -> getNode ( $ nodeName ) ; if ( $ node -> hasProperty ( self :: NODE_HISTORY_FIELD ) ) { return ; } $ event -> setNode ( $ node ) ; $ event -> setParentNode ( $ parentNode ) ; }
Receives node for route and overwrite when the node is empty.

@param PersistEvent $event
Receives node for route and overwrite when the node is empty .