Skip to content

Commit

Permalink
use exist route object for route generation (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored and wachterjohannes committed May 3, 2017
1 parent 74b8090 commit e862d96
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Document/Subscriber/RoutableSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down

0 comments on commit e862d96

Please sign in to comment.