diff --git a/Classes/Controller/Frontend/FrontendController.php b/Classes/Controller/Frontend/FrontendController.php index 9723924fa..70bd5508d 100644 --- a/Classes/Controller/Frontend/FrontendController.php +++ b/Classes/Controller/Frontend/FrontendController.php @@ -4,6 +4,7 @@ namespace Tvp\TemplaVoilaPlus\Controller\Frontend; +use Psr\Http\Message\ServerRequestInterface; use Tvp\TemplaVoilaPlus\Configuration\FlexForm\FlexFormTools8; use Tvp\TemplaVoilaPlus\Domain\Model\Configuration\DataConfiguration; use Tvp\TemplaVoilaPlus\Domain\Model\Configuration\MappingConfiguration; @@ -57,7 +58,7 @@ public function __construct() * page.10.userFunc = Tvp\TemplaVoilaPlus\Controller\Frontend\FrontendController->renderPage */ // phpcs:disable - public function main_page($content, $conf) + public function main_page($content, $conf, ServerRequestInterface $request) { // phpcs:enable trigger_error( @@ -66,7 +67,7 @@ public function main_page($content, $conf) 'please change to "Tvp\TemplaVoilaPlus\Controller\Frontend\FrontendController->renderPage"', E_USER_DEPRECATED ); - return $this->renderPage($content, $conf); + return $this->renderPage($content, $conf, $request); } /** @@ -78,7 +79,7 @@ public function main_page($content, $conf) * @return string HTML content for the Flexible Content elements. * @throws \InvalidArgumentException */ - public function renderPage($content, $conf) + public function renderPage($content, $conf, ServerRequestInterface $request) { /** @var ApiService */ $apiService = GeneralUtility::makeInstance(ApiService::class, 'pages'); @@ -122,12 +123,12 @@ public function renderPage($content, $conf) ); } - return $this->renderElement($pageRecord, 'pages', $conf); + return $this->renderElement($pageRecord, 'pages', $conf, $request); } - public function renderContent($content, $conf) + public function renderContent($content, $conf, ServerRequestInterface $request) { - return $this->renderElement($this->cObj->data, 'tt_content', $conf); + return $this->renderElement($this->cObj->data, 'tt_content', $conf, $request); } /** @@ -142,7 +143,7 @@ public function renderContent($content, $conf) * @throws \Exception * */ - public function renderElement($row, $table, array $conf) + public function renderElement($row, $table, array $conf, ServerRequestInterface $request) { try { // pages where checked for empty map already, but not tt_content @@ -206,7 +207,7 @@ public function renderElement($row, $table, array $conf) PageBasicsHandler::processConfiguration($templateConfiguration, $this->frontendController); // give TemplateData to renderer and return result - return $renderer->renderTemplate($templateConfiguration, $processedValues, $row); + return $renderer->renderTemplate($templateConfiguration, $processedValues, $row, $request); } catch (\Exception $e) { // only log if $table is tt_content and exception is for tt_content, because elso it will be logged twice if ($e instanceof ContentElementWithoutMapException && $table == 'tt_content') { diff --git a/Classes/Handler/Render/FluidRenderHandler.php b/Classes/Handler/Render/FluidRenderHandler.php index badcafd65..ada15fff5 100644 --- a/Classes/Handler/Render/FluidRenderHandler.php +++ b/Classes/Handler/Render/FluidRenderHandler.php @@ -17,6 +17,7 @@ * The TYPO3 project - inspiring people to share! */ +use Psr\Http\Message\ServerRequestInterface; use Tvp\TemplaVoilaPlus\Domain\Model\Configuration\TemplateConfiguration; use Tvp\TemplaVoilaPlus\Handler\Render\RenderHandlerInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -26,13 +27,14 @@ class FluidRenderHandler implements RenderHandlerInterface { public static $identifier = 'TVP\Renderer\Fluid'; - public function renderTemplate(TemplateConfiguration $templateConfiguration, array $processedValues, array $row): string + public function renderTemplate(TemplateConfiguration $templateConfiguration, array $processedValues, array $row, ServerRequestInterface $request): string { /** @var StandaloneView */ $view = GeneralUtility::makeInstance(StandaloneView::class); $path = GeneralUtility::getFileAbsFileName($templateConfiguration->getPlace()->getEntryPoint()); $options = $templateConfiguration->getOptions(); + $view->setRequest($request); /** @TODO Check if template file otherwise bad error messages will happen */ $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateConfiguration->getTemplateFileName())); diff --git a/Classes/Handler/Render/MarkerBasedRenderHandler.php b/Classes/Handler/Render/MarkerBasedRenderHandler.php index a92a12064..abba691f0 100644 --- a/Classes/Handler/Render/MarkerBasedRenderHandler.php +++ b/Classes/Handler/Render/MarkerBasedRenderHandler.php @@ -17,6 +17,7 @@ * The TYPO3 project - inspiring people to share! */ +use Psr\Http\Message\ServerRequestInterface; use Tvp\TemplaVoilaPlus\Domain\Model\Configuration\TemplateConfiguration; use TYPO3\CMS\Core\Service\MarkerBasedTemplateService; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -25,7 +26,7 @@ class MarkerBasedRenderHandler implements RenderHandlerInterface { public static $identifier = 'TVP\Renderer\MarkerBased'; - public function renderTemplate(TemplateConfiguration $templateConfiguration, array $processedValues, array $row): string + public function renderTemplate(TemplateConfiguration $templateConfiguration, array $processedValues, array $row, ServerRequestInterface $request): string { /** @var MarkerBasedTemplateService */ $markerBasedTemplateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class); diff --git a/Classes/Handler/Render/RenderHandlerInterface.php b/Classes/Handler/Render/RenderHandlerInterface.php index 311d33129..65b4bec9d 100644 --- a/Classes/Handler/Render/RenderHandlerInterface.php +++ b/Classes/Handler/Render/RenderHandlerInterface.php @@ -17,9 +17,10 @@ * The TYPO3 project - inspiring people to share! */ +use Psr\Http\Message\ServerRequestInterface; use Tvp\TemplaVoilaPlus\Domain\Model\Configuration\TemplateConfiguration; interface RenderHandlerInterface { - public function renderTemplate(TemplateConfiguration $templateConfiguration, array $processedValues, array $row): string; + public function renderTemplate(TemplateConfiguration $templateConfiguration, array $processedValues, array $row, ServerRequestInterface $request): string; } diff --git a/Classes/Handler/Render/XpathRenderHandler.php b/Classes/Handler/Render/XpathRenderHandler.php index d9c998096..d68a41312 100644 --- a/Classes/Handler/Render/XpathRenderHandler.php +++ b/Classes/Handler/Render/XpathRenderHandler.php @@ -16,6 +16,8 @@ * * The TYPO3 project - inspiring people to share! */ + +use Psr\Http\Message\ServerRequestInterface; use Tvp\TemplaVoilaPlus\Domain\Model\Configuration\TemplateConfiguration; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -28,7 +30,7 @@ class XpathRenderHandler implements RenderHandlerInterface protected $domDocument; protected $domXpath; - public function renderTemplate(TemplateConfiguration $templateConfiguration, array $processedValues, array $row): string + public function renderTemplate(TemplateConfiguration $templateConfiguration, array $processedValues, array $row, ServerRequestInterface $request): string { $this->domDocument = new \DOMDocument(); libxml_use_internal_errors(true); diff --git a/Classes/ViewHelpers/RenderLayoutViewHelper.php b/Classes/ViewHelpers/RenderLayoutViewHelper.php index 1505800e5..0eac61a5b 100644 --- a/Classes/ViewHelpers/RenderLayoutViewHelper.php +++ b/Classes/ViewHelpers/RenderLayoutViewHelper.php @@ -57,6 +57,6 @@ public static function renderStatic( $backendLayoutConfiguration = ApiHelperUtility::getBackendLayoutConfiguration($combinedConfigurationIdentifier); $renderer = $configurationService->getHandler($backendLayoutConfiguration->getRenderHandlerIdentifier()); - return $renderer->renderTemplate($backendLayoutConfiguration, $variables, []); + return $renderer->renderTemplate($backendLayoutConfiguration, $variables, [], $renderingContext->getRequest()); } }