Skip to content

Commit

Permalink
Set VBP's status to unpublished when BE is not visible on front (and …
Browse files Browse the repository at this point in the history
…do not show it in sitemap)
  • Loading branch information
Leny Bernard committed Apr 1, 2019
1 parent 2bdcf7d commit cf3c90e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Victoire\Bundle\BusinessPageBundle\Entity\VirtualBusinessPage;
use Victoire\Bundle\CoreBundle\Exception\IdentifierNotDefinedException;
use Victoire\Bundle\CoreBundle\Helper\UrlBuilder;
use Victoire\Bundle\PageBundle\Entity\PageStatus;
use Victoire\Bundle\ViewReferenceBundle\Builder\ViewReferenceBuilder;

/**
Expand Down Expand Up @@ -272,6 +273,9 @@ private function populatePage(VirtualBusinessPage $page, BusinessTemplate $busin
$page->setSlug($pageSlug);
$page->setName($pageName);
$page->setReference($this->viewReferenceBuilder->buildViewReference($page, $em));
if (false === $entity->isVisibleOnFront()) {
$page->setStatus(PageStatus::UNPUBLISHED);
}

return $page;
}
Expand Down
6 changes: 4 additions & 2 deletions Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ private function getBusinessPages(ViewReference $tree, $businessPages = [])
) {
/** @var WebViewInterface $businessPage */
$businessPage = $this->pageHelper->findPageByReference($child);
$businessPage->setReference($child);
$businessPages[] = $businessPage;
if ($businessPage->isPublished()) {
$businessPage->setReference($child);
$businessPages[] = $businessPage;
}
}
$businessPages = $this->getBusinessPages($child, $businessPages);
}
Expand Down

0 comments on commit cf3c90e

Please sign in to comment.