diff --git a/cms/modules/section/render.html.twig b/cms/modules/section/render.html.twig index 3fd68fd..7f7bd98 100644 --- a/cms/modules/section/render.html.twig +++ b/cms/modules/section/render.html.twig @@ -26,7 +26,7 @@ {% else %} - {{ render(url('sfs_cms_section_render', {'section': section.id, '_locale':app.request.locale})) }} + {{ render(url('sfs_cms_section_render', {'section': section.id, '_locale':app.request.locale, 'do_not_throw_not_found': true})) }} {% endif %} {% if id|default(false) or class|default(false) %}{% endif %} {% endif %} diff --git a/src/Controller/SectionController.php b/src/Controller/SectionController.php index b933453..5453d13 100644 --- a/src/Controller/SectionController.php +++ b/src/Controller/SectionController.php @@ -50,6 +50,10 @@ public function renderById(string $section, Request $request, bool $adminPreview if (!$section) { $this->cmsLogger && $this->cmsLogger->error(sprintf('CMS missing section %s', $section)); + if ($request->get('do_not_throw_not_found')) { + return $response; + } + throw $this->createNotFoundException(sprintf('Section with id "%s" not found.', $section)); } @@ -71,6 +75,10 @@ public function renderById(string $section, Request $request, bool $adminPreview } if (!$publishedVersion) { + if ($request->get('do_not_throw_not_found')) { + return $response; + } + throw $this->createNotFoundException(); } diff --git a/src/Doctrine/EventListener/ContentVersionSectionRelationshipListener.php b/src/Doctrine/EventListener/ContentVersionSectionRelationshipListener.php index f221efe..2e2e2fc 100644 --- a/src/Doctrine/EventListener/ContentVersionSectionRelationshipListener.php +++ b/src/Doctrine/EventListener/ContentVersionSectionRelationshipListener.php @@ -28,7 +28,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void $metadata->mapManyToMany([ 'fieldName' => 'sections', 'targetEntity' => $sectionMetadata->getName(), - 'fetch' => 'EXTRA_LAZY', + 'fetch' => ClassMetadata::FETCH_EXTRA_LAZY, 'joinTable' => [ 'name' => 'cms_content_version_sections', 'joinColumns' => [