From e862d9658a959c4cf79a734662f939a8ac8374d4 Mon Sep 17 00:00:00 2001 From: L91 Date: Wed, 3 May 2017 16:15:24 +0200 Subject: [PATCH] use exist route object for route generation (#166) --- Document/Subscriber/RoutableSubscriber.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Document/Subscriber/RoutableSubscriber.php b/Document/Subscriber/RoutableSubscriber.php index 0cac1bf58..19068b58c 100644 --- a/Document/Subscriber/RoutableSubscriber.php +++ b/Document/Subscriber/RoutableSubscriber.php @@ -235,7 +235,12 @@ public function handlePublish(PublishEvent $event) */ private function createOrUpdatePageRoute(RoutablePageBehavior $document, $locale) { - $route = $this->routeRepository->findByEntity($document->getClass(), $document->getUuid(), $locale); + $route = $document->getRoute(); + + if (!$route) { + $route = $this->routeRepository->findByEntity($document->getClass(), $document->getUuid(), $locale); + } + if ($route) { $document->setRoute($route); @@ -255,7 +260,12 @@ private function createOrUpdatePageRoute(RoutablePageBehavior $document, $locale */ private function createOrUpdateRoute(RoutableBehavior $document, $locale) { - $route = $this->routeRepository->findByEntity($document->getClass(), $document->getUuid(), $locale); + $route = $document->getRoute(); + + if (!$route) { + $route = $this->routeRepository->findByEntity($document->getClass(), $document->getUuid(), $locale); + } + if ($route) { $document->setRoute($route);