Skip to content

Commit

Permalink
[BUGFIX] Exception for CEs with language -1
Browse files Browse the repository at this point in the history
  • Loading branch information
kitzberger committed Aug 14, 2024
1 parent 38cbc50 commit 38749b1
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ public function __invoke(AfterPagePreviewUriGeneratedEvent $event): void

try {
$site = $this->siteFinder->getSiteByPageId($event->getPageId());
$languageUid = $event->getLanguageId();
$language = $languageUid === -1 ? null : $site->getLanguageById($languageUid);

$headlessMode = GeneralUtility::makeInstance(HeadlessMode::class);
$headlessMode = $headlessMode->withRequest($GLOBALS['TYPO3_REQUEST']);
$request = $headlessMode->overrideBackendRequestBySite($site, $site->getLanguageById($event->getLanguageId()));
$request = $headlessMode->overrideBackendRequestBySite($site, $language);

$urlUtility = $this->urlUtility->withRequest($request);
$event->setPreviewUri(new Uri($urlUtility->getFrontendUrlWithSite($event->getPreviewUri()->__toString(), $site)));
Expand Down

0 comments on commit 38749b1

Please sign in to comment.