1414use TYPO3 \CMS \Core \Pagination \SimplePagination ;
1515use TYPO3 \CMS \Core \Utility \ArrayUtility ;
1616use TYPO3 \CMS \Core \Utility \GeneralUtility ;
17+ use TYPO3 \CMS \Core \View \ViewFactoryData ;
18+ use TYPO3 \CMS \Core \View \ViewFactoryInterface ;
19+ use TYPO3 \CMS \Core \View \ViewInterface ;
1720use TYPO3 \CMS \Extbase \Configuration \ConfigurationManager ;
1821use TYPO3 \CMS \Extbase \Configuration \ConfigurationManagerInterface ;
1922use TYPO3 \CMS \Extbase \Pagination \QueryResultPaginator ;
2023use TYPO3 \CMS \Extbase \Persistence \QueryResultInterface ;
21- use TYPO3 \CMS \Fluid \Core \Rendering \RenderingContext ;
22- use TYPO3 \CMS \Fluid \Core \Rendering \RenderingContextFactory ;
23- use TYPO3 \CMS \Fluid \View \StandaloneView ;
2424use TYPO3Fluid \Fluid \Core \Rendering \RenderingContextInterface ;
2525use TYPO3Fluid \Fluid \Core \ViewHelper \AbstractViewHelper ;
2626
@@ -34,6 +34,11 @@ class PaginateViewHelper extends AbstractViewHelper
3434 */
3535 protected $ escapeOutput = false ;
3636
37+ public function __construct (
38+ protected readonly ViewFactoryInterface $ viewFactory ,
39+ ) {
40+ }
41+
3742 public function initializeArguments (): void
3843 {
3944 parent ::initializeArguments ();
@@ -78,7 +83,7 @@ public function render(): string
7883 'pagination ' => $ pagination ,
7984 'configuration ' => $ configuration ,
8085 ]);
81- $ paginationRendered = $ paginationView ->render ();
86+ $ paginationRendered = $ paginationView ->render (' Paginate/Index ' );
8287
8388 $ variableProvider = $ renderingContext ->getVariableProvider ();
8489 $ variableProvider ->add ('paginator ' , $ paginator );
@@ -99,20 +104,10 @@ public function render(): string
99104 );
100105 }
101106
102- protected function getTemplateObject (RenderingContextInterface $ renderingContext , ServerRequestInterface $ request ): StandaloneView
107+ protected function getTemplateObject (RenderingContextInterface $ renderingContext , ServerRequestInterface $ request ): ViewInterface
103108 {
104109 $ setup = $ this ->getConfigurationManager ()->getConfiguration (ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT );
105110
106- /** @phpstan-ignore-next-line */
107- $ context = GeneralUtility::makeInstance (RenderingContextFactory::class)->create ([], $ request );
108- if ((new \ReflectionMethod (RenderingContextFactory::class, 'create ' ))->getNumberOfParameters () === 1 ) {
109- /** @phpstan-ignore-next-line */
110- $ context ->setRequest ($ request );
111- }
112-
113- /** @var StandaloneView $view */
114- $ view = GeneralUtility::makeInstance (StandaloneView::class, $ context );
115-
116111 $ layoutRootPaths = [];
117112 $ layoutRootPaths [] = GeneralUtility::getFileAbsFileName ('EXT:bootstrap_package/Resources/Private/Layouts/ViewHelpers/ ' );
118113 if (isset ($ setup ['plugin. ' ]['tx_bootstrappackage. ' ]['view. ' ]['layoutRootPaths. ' ])) {
@@ -135,12 +130,12 @@ protected function getTemplateObject(RenderingContextInterface $renderingContext
135130 }
136131 }
137132
138- $ view -> setLayoutRootPaths ( $ layoutRootPaths );
139- $ view -> setPartialRootPaths ( $ partialRootPaths );
140- $ view -> setTemplateRootPaths ( $ templateRootPaths );
141- $ view -> setTemplate ( ' Paginate/Index ' );
142-
143- return $ view ;
133+ return $ this -> viewFactory -> create ( new ViewFactoryData (
134+ templateRootPaths: $ templateRootPaths ,
135+ partialRootPaths: $ partialRootPaths ,
136+ layoutRootPaths: $ layoutRootPaths ,
137+ request: $ request ,
138+ )) ;
144139 }
145140
146141 protected function getConfigurationManager (): ConfigurationManagerInterface
@@ -155,9 +150,6 @@ protected function getRequestFromRenderingContext(RenderingContextInterface $ren
155150 {
156151 if ($ renderingContext ->hasAttribute (ServerRequestInterface::class)) {
157152 return $ renderingContext ->getAttribute (ServerRequestInterface::class);
158- } elseif ($ renderingContext instanceof RenderingContext) {
159- /** @phpstan-ignore-next-line */
160- return $ renderingContext ->getRequest ();
161153 }
162154
163155 return null ;
0 commit comments