Skip to content

Commit

Permalink
fix compatability with content-bundle (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed Nov 15, 2021
1 parent aed0fca commit 8544626
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Content/ContentTypeResolver/AccountSelectionResolver.php
Expand Up @@ -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]);
}
}
2 changes: 1 addition & 1 deletion Content/ContentTypeResolver/CategorySelectionResolver.php
Expand Up @@ -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]);
}
}
Expand Up @@ -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]);
}
}
2 changes: 1 addition & 1 deletion Content/ContentTypeResolver/ContactSelectionResolver.php
Expand Up @@ -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]);
}
}
2 changes: 1 addition & 1 deletion Content/ContentTypeResolver/PageSelectionResolver.php
Expand Up @@ -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]);
}
}
13 changes: 8 additions & 5 deletions Content/StructureResolver.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8544626

Please sign in to comment.