From cf3c90e439b7e715e3a2c4b00c5e5ca2f7ba4eca Mon Sep 17 00:00:00 2001 From: Leny Bernard Date: Tue, 2 Apr 2019 00:18:18 +0200 Subject: [PATCH] Set VBP's status to unpublished when BE is not visible on front (and do not show it in sitemap) --- Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php | 4 ++++ Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php b/Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php index 04a44bee3..4482aeeb5 100644 --- a/Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php +++ b/Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php @@ -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; /** @@ -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; } diff --git a/Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php b/Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php index d1e324b41..88a5d6253 100644 --- a/Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php +++ b/Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php @@ -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); }