Skip to content

Commit

Permalink
build i18n context if document is a fallback document
Browse files Browse the repository at this point in the history
fix #105
  • Loading branch information
pascalmoser committed Oct 17, 2022
1 parent 7b70f8b commit 7cfe366
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/I18nBundle/EventListener/I18nStartupListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function onKernelRequest(RequestEvent $event): void
return;
}

if ($document instanceof Document\Link) {
if ($document instanceof Document\Link && !$this->pimcoreDocumentResolver->isFallbackDocument($document)) {
// only skip context building if the *requested* document is a link
return;
}

Expand Down
9 changes: 9 additions & 0 deletions src/I18nBundle/Resolver/PimcoreDocumentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public function getDocument(Request $request): ?Document
return $this->findFallback($request);
}

public function isFallbackDocument(Document $document): bool
{
if (!$this->nearestDocument instanceof Document) {
return false;
}

return $this->nearestDocument->getId() === $document->getId();
}

protected function findFallback(Request $request): ?Document
{
if (!$this->requestHelper->matchesDefaultPimcoreContext($request)) {
Expand Down
2 changes: 2 additions & 0 deletions src/I18nBundle/Resolver/PimcoreDocumentResolverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
interface PimcoreDocumentResolverInterface
{
public function getDocument(Request $request): ?Document;

public function isFallbackDocument(Document $document): bool;
}

0 comments on commit 7cfe366

Please sign in to comment.