Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build i18n context if document is a fallback document #106

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Upgrade Notes


## 4.1.0
- [BUGFIX] I18nContext is missing in static routes if fallback document is an instance of Document\Link [#105](https://github.com/dachcom-digital/pimcore-i18n/issues/105)
## 4.0.6
- [BUGFIX] Fix missing site attribute in error page [#107](https://github.com/dachcom-digital/pimcore-i18n/issues/107)
## 4.0.5
Expand Down
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;
}