Skip to content

Commit

Permalink
Fix smartcontent properties and page selection for non exist properti…
Browse files Browse the repository at this point in the history
…es (#95)
  • Loading branch information
popoplanter authored Jun 9, 2021
1 parent df9c375 commit edf1c60
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Content/StructureResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ public function resolveProperties(
if (false !== strpos($sourceProperty, '.')) {
[$extensionName, $propertyName] = explode('.', $sourceProperty);

$contentView = new ContentView($unresolvedExtensionData[$extensionName][$propertyName] ?? null);
if (!isset($unresolvedExtensionData[$extensionName][$propertyName])) {
continue;
}

$contentView = new ContentView($unresolvedExtensionData[$extensionName][$propertyName]);
if ('excerpt' === $extensionName) {
$contentView = $this->resolveProperty(
$excerptStructure,
Expand All @@ -129,7 +133,12 @@ public function resolveProperties(
);
}
} else {
if (!$structure->hasProperty($sourceProperty)) {
continue;
}

$property = $structure->getProperty($sourceProperty);

$contentView = $this->resolveProperty(
$structure,
$sourceProperty,
Expand Down
1 change: 1 addition & 0 deletions Controller/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function getAction(Request $request, string $context): Response
$webspace = $attributes->getAttribute('webspace');
$locale = $request->getLocale();

/** @var string $uuid */
$uuid = $request->query->get('uuid');
$depth = (int) $this->getRequestParameter($request, 'depth', false, 1);
$flat = $this->getBooleanRequestParameter($request, 'flat', false, false);
Expand Down
11 changes: 10 additions & 1 deletion Tests/Unit/Content/StructureResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ public function testResolveProperties(): void
$titleProperty->getValue()->willReturn('test-123');
$titleProperty->setValue('test-123')->shouldBeCalled();

$structure->hasProperty('title')->willReturn(true);
$structure->getProperty('title')->willReturn($titleProperty->reveal());
$structure->hasProperty('notExist')->willReturn(false);

$titleContentView = $this->prophesize(ContentView::class);
$titleContentView->getContent()->willReturn('test-123');
Expand All @@ -512,7 +514,13 @@ public function testResolveProperties(): void
// call test function
$result = $this->structureResolver->resolveProperties(
$structure->reveal(),
['myTitle' => 'title', 'seoDescription' => 'seo.description', 'excerptTitle' => 'excerpt.title'],
[
'myTitle' => 'title',
'seoDescription' => 'seo.description',
'excerptTitle' => 'excerpt.title',
'notExist' => 'notExist',
'excerptNotExist' => 'excerpt.notExist',
],
'en'
);

Expand Down Expand Up @@ -591,6 +599,7 @@ public function testResolvePropertiesIncludeExtension(): void
$titleProperty->getValue()->willReturn('test-123');
$titleProperty->setValue('test-123')->shouldBeCalled();

$structure->hasProperty('title')->willReturn(true);
$structure->getProperty('title')->willReturn($titleProperty->reveal());

$titleContentView = $this->prophesize(ContentView::class);
Expand Down

0 comments on commit edf1c60

Please sign in to comment.