Skip to content

Commit

Permalink
PageModel is not optional
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jul 9, 2020
1 parent 793b3d5 commit 4692bcc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core-bundle/src/Controller/Page/RootController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getUrlSuffixes(): array
;
}

public function supportsContentComposition(PageModel $pageModel = null): bool
public function supportsContentComposition(PageModel $pageModel): bool
{
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/src/Routing/Page/CompositionAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ interface CompositionAwareInterface
* Most Contao page types do support composition. Pages that do not support composition
* can be structural (e.g. a redirect page) or functional (e.g. an XML sitemap).
*
* The optional $pageModel might tell if a particular page supports composition,
* The $pageModel might tell if a particular page supports composition,
* for example a 404 page that redirects cannot have articles, but a regular 404 does.
*/
public function supportsContentComposition(PageModel $pageModel = null): bool;
public function supportsContentComposition(PageModel $pageModel): bool;
}
5 changes: 4 additions & 1 deletion core-bundle/src/Routing/Page/PageRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public function supportsContentComposition(PageModel $pageModel): bool
return true;
}

return $this->compositionAware[$pageModel->type]->supportsContentComposition($pageModel);
/** @var CompositionAwareInterface $service */
$service = $this->compositionAware[$pageModel->type];

return $service->supportsContentComposition($pageModel);
}

public function add(string $type, RouteConfig $config, PageRouteEnhancerInterface $routeEnhancer = null, CompositionAwareInterface $compositionAware = null): self
Expand Down
5 changes: 4 additions & 1 deletion core-bundle/tests/Controller/Page/RootControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public function testReturnsUrlSuffixesFromDatabase(): void

public function testDoesNotSupportContentComposition(): void
{
$this->assertFalse($this->controller->supportsContentComposition());
/** @var PageModel&MockObject $page */
$page = $this->mockClassWithProperties(PageModel::class);

$this->assertFalse($this->controller->supportsContentComposition($page));
}
}

0 comments on commit 4692bcc

Please sign in to comment.