Skip to content

Commit

Permalink
[BUGFIX] Forward request to Fluid preview renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrodala committed May 21, 2024
1 parent eefd713 commit 2b31182
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Classes/Indexer/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PAGEmachine\Searchable\LinkBuilder\PageLinkBuilder;
use PAGEmachine\Searchable\Preview\DefaultPreviewRenderer;
use PAGEmachine\Searchable\Preview\PreviewRendererInterface;
use PAGEmachine\Searchable\Preview\RequestAwarePreviewRendererInterface;
use PAGEmachine\Searchable\Query\BulkQuery;
use PAGEmachine\Searchable\Query\UpdateQuery;
use PAGEmachine\Searchable\Service\ExtconfService;
Expand Down Expand Up @@ -244,6 +245,10 @@ public function run()
{
TsfeUtility::createTSFE($this->config['siteIdentifier'] ?? null, $this->language);

if (is_a($this->previewRenderer, RequestAwarePreviewRendererInterface::class)) {
$this->previewRenderer->setRequest($GLOBALS['TYPO3_REQUEST']);
}

$bulkSize = ($this->config['bulkSize'] ?? null) ?: 20;

$counter = 0;
Expand Down Expand Up @@ -287,6 +292,10 @@ public function runUpdate()
{
TsfeUtility::createTSFE($this->config['siteIdentifier'] ?? null, $this->language);

if (is_a($this->previewRenderer, RequestAwarePreviewRendererInterface::class)) {
$this->previewRenderer->setRequest($GLOBALS['TYPO3_REQUEST']);
}

$bulkSize = ($this->config['bulkSize'] ?? null) ?: 20;

$counter = 0;
Expand Down
8 changes: 7 additions & 1 deletion Classes/Preview/FluidPreviewRenderer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace PAGEmachine\Searchable\Preview;

use PAGEmachine\Searchable\Preview\RequestAwarePreviewRendererInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
Expand All @@ -13,7 +15,7 @@
/**
* Fluid Preview Renderer. Uses a Fluid Standalone View to render previews
*/
class FluidPreviewRenderer extends AbstractPreviewRenderer implements PreviewRendererInterface
class FluidPreviewRenderer extends AbstractPreviewRenderer implements PreviewRendererInterface, RequestAwarePreviewRendererInterface
{
/**
* @var StandaloneView $view
Expand All @@ -34,6 +36,10 @@ public function __construct(...$arguments)

$this->prepareView();
}
public function setRequest(ServerRequestInterface $request): void
{
$this->view->setRequest($request);
}

/**
* Renders the preview
Expand Down
13 changes: 13 additions & 0 deletions Classes/Preview/RequestAwarePreviewRendererInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace PAGEmachine\Searchable\Preview;

/*
* This file is part of the PAGEmachine Searchable project.
*/

use Psr\Http\Message\ServerRequestInterface;

interface RequestAwarePreviewRendererInterface
{
public function setRequest(ServerRequestInterface $request): void;
}
2 changes: 2 additions & 0 deletions Classes/Utility/TsfeUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public static function createTSFE(string $siteIdentifier = null, int $languageId

if ((new Typo3Version())->getMajorVersion() < 12) {
$frontendController->getConfigArray($request);
} else {
$GLOBALS['TYPO3_REQUEST'] = $frontendController->getFromCache($GLOBALS['TYPO3_REQUEST']);
}

$GLOBALS['TSFE'] = $frontendController;
Expand Down

0 comments on commit 2b31182

Please sign in to comment.