Skip to content

Commit

Permalink
[BUGFIX] Use proper ViewInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
ohader committed Oct 28, 2024
1 parent 9f10179 commit 303f2ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
21 changes: 7 additions & 14 deletions Classes/ViewHelpers/Data/PaginateViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\View\ViewFactoryData;
use TYPO3\CMS\Core\View\ViewFactoryInterface;
use TYPO3\CMS\Core\View\ViewInterface;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\View\ViewInterface as FluidStandaloneViewInterface;

/**
* PaginateViewHelper
Expand All @@ -37,9 +36,9 @@ class PaginateViewHelper extends AbstractViewHelper
*/
protected $escapeOutput = false;

public function __construct(protected ViewFactoryInterface $viewFactory)
{
}
public function __construct(
protected readonly ViewFactoryInterface $viewFactory,
) {}

public function initializeArguments(): void
{
Expand Down Expand Up @@ -106,7 +105,7 @@ public function render(): string
);
}

protected function getTemplateObject(RenderingContextInterface $renderingContext, ServerRequestInterface $request): FluidStandaloneViewInterface
protected function getTemplateObject(RenderingContextInterface $renderingContext, ServerRequestInterface $request): ViewInterface
{
$setup = $this->getConfigurationManager()->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);

Expand All @@ -117,9 +116,6 @@ protected function getTemplateObject(RenderingContextInterface $renderingContext
$context->setRequest($request);
}

/** @var StandaloneView $view */
$view = GeneralUtility::makeInstance(StandaloneView::class, $context);

$layoutRootPaths = [];
$layoutRootPaths[] = GeneralUtility::getFileAbsFileName('EXT:bootstrap_package/Resources/Private/Layouts/ViewHelpers/');
if (isset($setup['plugin.']['tx_bootstrappackage.']['view.']['layoutRootPaths.'])) {
Expand All @@ -142,15 +138,12 @@ protected function getTemplateObject(RenderingContextInterface $renderingContext
}
}

$viewFactoryData = new ViewFactoryData(
return $this->viewFactory->create(new ViewFactoryData(
templateRootPaths: $templateRootPaths,
partialRootPaths: $partialRootPaths,
layoutRootPaths: $layoutRootPaths,
request: $request,
);
$view = $this->viewFactory->create($viewFactoryData);

return $view;
));
}

protected function getConfigurationManager(): ConfigurationManagerInterface
Expand Down
17 changes: 7 additions & 10 deletions Classes/ViewHelpers/FrameViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\View\ViewFactoryData;
use TYPO3\CMS\Core\View\ViewFactoryInterface;
use TYPO3\CMS\Core\View\ViewInterface;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\View\ViewInterface as FluidStandaloneViewInterface;

/**
* FrameViewHelper
Expand All @@ -34,9 +34,9 @@ class FrameViewHelper extends AbstractViewHelper
*/
protected $escapeOutput = false;

public function __construct(protected ViewFactoryInterface $viewFactory)
{
}
public function __construct(
protected readonly ViewFactoryInterface $viewFactory,
) {}

public function initializeArguments(): void
{
Expand Down Expand Up @@ -174,7 +174,7 @@ public function render()
return $view->render('Frame/Index');
}

protected function getTemplateObject(): FluidStandaloneViewInterface
protected function getTemplateObject(): ViewInterface
{
$setup = static::getConfigurationManager()->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);

Expand All @@ -200,15 +200,12 @@ protected function getTemplateObject(): FluidStandaloneViewInterface
}
}

$viewFactoryData = new ViewFactoryData(
return $this->viewFactory->create(new ViewFactoryData(
templateRootPaths: $templateRootPaths,
partialRootPaths: $partialRootPaths,
layoutRootPaths: $layoutRootPaths,
request: $this->getRequestFromRenderingContext($this->renderingContext),
);
$view = $this->viewFactory->create($viewFactoryData);

return $view;
));
}

protected static function getConfigurationManager(): ConfigurationManagerInterface
Expand Down

0 comments on commit 303f2ba

Please sign in to comment.