From 8544626b727ea90fff4168c96e3975dc1298e63a Mon Sep 17 00:00:00 2001 From: Johannes Wachter Date: Mon, 15 Nov 2021 13:57:51 +0100 Subject: [PATCH] fix compatability with content-bundle (#102) --- .../AccountSelectionResolver.php | 2 +- .../CategorySelectionResolver.php | 2 +- .../ContactAccountSelectionResolver.php | 2 +- .../ContactSelectionResolver.php | 2 +- .../ContentTypeResolver/PageSelectionResolver.php | 2 +- Content/StructureResolver.php | 13 ++++++++----- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Content/ContentTypeResolver/AccountSelectionResolver.php b/Content/ContentTypeResolver/AccountSelectionResolver.php index 14153e4..a79f6b1 100644 --- a/Content/ContentTypeResolver/AccountSelectionResolver.php +++ b/Content/ContentTypeResolver/AccountSelectionResolver.php @@ -58,6 +58,6 @@ public function resolve($data, PropertyInterface $property, string $locale, arra $content[] = $this->accountSerializer->serialize($account->getEntity(), $locale, $serializationContext); } - return new ContentView($content, ['ids' => $data ?: []]); + return new ContentView($content, ['ids' => $data]); } } diff --git a/Content/ContentTypeResolver/CategorySelectionResolver.php b/Content/ContentTypeResolver/CategorySelectionResolver.php index b8fc4da..94e5c9d 100644 --- a/Content/ContentTypeResolver/CategorySelectionResolver.php +++ b/Content/ContentTypeResolver/CategorySelectionResolver.php @@ -59,6 +59,6 @@ public function resolve($data, PropertyInterface $property, string $locale, arra $serializedCategories[] = $this->categorySerializer->serialize($category, $locale, $serializationContext); } - return new ContentView($serializedCategories, ['ids' => $data ?: []]); + return new ContentView($serializedCategories, ['ids' => $data]); } } diff --git a/Content/ContentTypeResolver/ContactAccountSelectionResolver.php b/Content/ContentTypeResolver/ContactAccountSelectionResolver.php index 180b156..488e7f0 100644 --- a/Content/ContentTypeResolver/ContactAccountSelectionResolver.php +++ b/Content/ContentTypeResolver/ContactAccountSelectionResolver.php @@ -82,6 +82,6 @@ public function resolve($data, PropertyInterface $property, string $locale, arra } } - return new ContentView($content, ['ids' => $data ?: []]); + return new ContentView($content, ['ids' => $data]); } } diff --git a/Content/ContentTypeResolver/ContactSelectionResolver.php b/Content/ContentTypeResolver/ContactSelectionResolver.php index 30045e3..c909ec4 100644 --- a/Content/ContentTypeResolver/ContactSelectionResolver.php +++ b/Content/ContentTypeResolver/ContactSelectionResolver.php @@ -58,6 +58,6 @@ public function resolve($data, PropertyInterface $property, string $locale, arra $content[] = $this->contactSerializer->serialize($contact->getEntity(), $locale, $serializationContext); } - return new ContentView($content, ['ids' => $data ?: []]); + return new ContentView($content, ['ids' => $data]); } } diff --git a/Content/ContentTypeResolver/PageSelectionResolver.php b/Content/ContentTypeResolver/PageSelectionResolver.php index 207ad0a..88a10f8 100644 --- a/Content/ContentTypeResolver/PageSelectionResolver.php +++ b/Content/ContentTypeResolver/PageSelectionResolver.php @@ -100,6 +100,6 @@ public function resolve($data, PropertyInterface $property, string $locale, arra $pages[] = $this->structureResolver->resolveProperties($pageStructure, $propertyMap, $locale); } - return new ContentView($pages, ['ids' => $data ?: []]); + return new ContentView($pages, ['ids' => $data]); } } diff --git a/Content/StructureResolver.php b/Content/StructureResolver.php index fd15f0d..a69f2e7 100644 --- a/Content/StructureResolver.php +++ b/Content/StructureResolver.php @@ -15,7 +15,6 @@ use Sulu\Bundle\DocumentManagerBundle\Bridge\DocumentInspector; use Sulu\Bundle\PageBundle\Document\BasePageDocument; -use Sulu\Bundle\PageBundle\Preview\PageRouteDefaultsProvider; use Sulu\Bundle\WebsiteBundle\ReferenceStore\ReferenceStoreNotExistsException; use Sulu\Bundle\WebsiteBundle\ReferenceStore\ReferenceStorePoolInterface; use Sulu\Component\Content\Compat\PropertyInterface; @@ -218,8 +217,10 @@ private function getProperties(StructureInterface $targetStructure, StructureInt * * @return mixed[] */ - private function getStructureData(StructureInterface $targetStructure, StructureInterface $requestedStructure): array - { + private function getStructureData( + StructureInterface $targetStructure, + StructureInterface $requestedStructure + ): array { $targetDocument = $targetStructure->getDocument(); $requestedDocument = $requestedStructure->getDocument(); @@ -416,9 +417,11 @@ private function getTemplateType(StructureInterface $structure, object $document private function getTargetStructure(StructureInterface $structure): StructureInterface { $document = $structure->getDocument(); + if (!$document instanceof RedirectTypeBehavior) { + return $structure; + } - while ($document instanceof RedirectTypeBehavior - && RedirectType::INTERNAL === $document->getRedirectType()) { + while ($document instanceof RedirectTypeBehavior && RedirectType::INTERNAL === $document->getRedirectType()) { $redirectTargetDocument = $document->getRedirectTarget(); if ($redirectTargetDocument instanceof StructureBehavior) {