src/Sulu/Component/Content/Document/Subscriber/RouteSubscriber.php
private function changeOldPathToHistoryRoutes(RouteBehavior $oldDocument, RouteBehavior $newDocument)
    {
        $oldDocument->setTargetDocument($newDocument);
        $oldDocument->setHistory(true);
        $oldRouteNode = $this->documentInspector->getNode($oldDocument);
        $oldRouteNode->setProperty(self::NODE_HISTORY_FIELD, true);

        foreach ($this->documentInspector->getReferrers($oldDocument) as $referrer) {
            if ($referrer instanceof RouteBehavior) {
                $referrer->setTargetDocument($newDocument);
                $referrer->setHistory(true);
                $this->documentManager->persist(
                    $referrer,
                    null,
                    [
                        'path' => $this->documentInspector->getPath($referrer),
                    ]
                );
                $this->documentManager->publish($referrer, null);
            }
        }
    }
private function changeOldPathToHistoryRoutes(RouteBehavior $oldDocument, RouteBehavior $newDocument)
    {
        $oldDocument->setTargetDocument($newDocument);
        $oldDocument->setHistory(true);
        $oldRouteNode = $this->documentInspector->getNode($oldDocument);
        $oldRouteNode->setProperty(self::NODE_HISTORY_FIELD, true);

        foreach ($this->documentInspector->getReferrers($oldDocument) as $referrer) {
            if ($referrer instanceof RouteBehavior) {
                $referrer->setTargetDocument($newDocument);
                $referrer->setHistory(true);
                $this->documentManager->persist(
                    $referrer,
                    null,
                    [
                        'path' => $this->documentInspector->getPath($referrer),
                    ]
                );
                $this->documentManager->publish($referrer, null);
            }
        }
    }
private function changeOldPathToHistoryRoutes ( RouteBehavior $ oldDocument , RouteBehavior $ newDocument ) { $ oldDocument -> setTargetDocument ( $ newDocument ) ; $ oldDocument -> setHistory ( true ) ; $ oldRouteNode = $ this -> documentInspector -> getNode ( $ oldDocument ) ; $ oldRouteNode -> setProperty ( self :: NODE_HISTORY_FIELD , true ) ; foreach ( $ this -> documentInspector -> getReferrers ( $ oldDocument ) as $ referrer ) { if ( $ referrer instanceof RouteBehavior ) { $ referrer -> setTargetDocument ( $ newDocument ) ; $ referrer -> setHistory ( true ) ; $ this -> documentManager -> persist ( $ referrer , null , [ 'path' => $ this -> documentInspector -> getPath ( $ referrer ) , ] ) ; $ this -> documentManager -> publish ( $ referrer , null ) ; } } }
Changes the old route to a history route and redirect to the new route.

@param RouteBehavior $oldDocument
@param RouteBehavior $newDocument
Changes the old route to a history route and redirect to the new route .