1818use B13 \Container \Domain \Factory \Exception ;
1919use B13 \Container \Domain \Factory \PageView \Backend \ContainerFactory ;
2020use B13 \Container \Events \BeforeContainerPreviewIsRenderedEvent ;
21+ use B13 \Container \Events \BeforeContainerPreviewIsRenderedEventV12 ;
2122use B13 \Container \Tca \Registry ;
2223use Psr \EventDispatcher \EventDispatcherInterface ;
2324use TYPO3 \CMS \Backend \Utility \BackendUtility ;
2425use TYPO3 \CMS \Backend \View \BackendLayout \Grid \Grid ;
25- use TYPO3 \CMS \Backend \View \BackendLayout \Grid \GridColumnItem ;
2626use TYPO3 \CMS \Backend \View \BackendLayout \Grid \GridRow ;
2727use TYPO3 \CMS \Backend \View \PageLayoutContext ;
2828use TYPO3 \CMS \Core \Authentication \BackendUserAuthentication ;
2929use TYPO3 \CMS \Core \Cache \Frontend \FrontendInterface ;
30+ use TYPO3 \CMS \Core \Information \Typo3Version ;
3031use TYPO3 \CMS \Core \Localization \LanguageService ;
3132use TYPO3 \CMS \Core \Utility \GeneralUtility ;
33+ use TYPO3 \CMS \Core \View \ViewFactoryData ;
34+ use TYPO3 \CMS \Core \View \ViewFactoryInterface ;
3235use TYPO3 \CMS \Fluid \View \StandaloneView ;
3336
3437class GridRenderer
@@ -86,10 +89,20 @@ public function renderGrid(array $record, PageLayoutContext $context): string
8689 $ gridTemplate = $ this ->tcaRegistry ->getGridTemplate ($ record ['CType ' ]);
8790 $ partialRootPaths = $ this ->tcaRegistry ->getGridPartialPaths ($ record ['CType ' ]);
8891 $ layoutRootPaths = $ this ->tcaRegistry ->getGridLayoutPaths ($ record ['CType ' ]);
89- $ view = GeneralUtility::makeInstance (StandaloneView::class);
90- $ view ->setPartialRootPaths ($ partialRootPaths );
91- $ view ->setLayoutRootPaths ($ layoutRootPaths );
92- $ view ->setTemplatePathAndFilename ($ gridTemplate );
92+ if ((GeneralUtility::makeInstance (Typo3Version::class))->getMajorVersion () < 13 ) {
93+ $ view = GeneralUtility::makeInstance (StandaloneView::class);
94+ $ view ->setPartialRootPaths ($ partialRootPaths );
95+ $ view ->setLayoutRootPaths ($ layoutRootPaths );
96+ $ view ->setTemplatePathAndFilename ($ gridTemplate );
97+ } else {
98+ $ viewFactory = GeneralUtility::makeInstance (ViewFactoryInterface::class);
99+ $ view = $ viewFactory ->create (new ViewFactoryData (
100+ null ,
101+ $ partialRootPaths ,
102+ $ layoutRootPaths ,
103+ $ gridTemplate
104+ ));
105+ }
93106
94107 $ view ->assign ('hideRestrictedColumns ' , (bool )(BackendUtility::getPagesTSconfig ($ context ->getPageId ())['mod. ' ]['web_layout. ' ]['hideRestrictedCols ' ] ?? false ));
95108 $ view ->assign ('newContentTitle ' , $ this ->getLanguageService ()->sL ('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:newContentElement ' ));
@@ -101,7 +114,11 @@ public function renderGrid(array $record, PageLayoutContext $context): string
101114 $ view ->assign ('containerRecord ' , $ record );
102115 $ view ->assign ('context ' , $ context );
103116 $ parentGridColumnItem = $ this ->runtimeCache ->get ('tx_container_current_gridColumItem ' );
104- $ beforeContainerPreviewIsRendered = new BeforeContainerPreviewIsRenderedEvent ($ container , $ view , $ grid , $ parentGridColumnItem );
117+ if ((GeneralUtility::makeInstance (Typo3Version::class))->getMajorVersion () < 13 ) {
118+ $ beforeContainerPreviewIsRendered = new BeforeContainerPreviewIsRenderedEventV12 ($ container , $ view , $ grid , $ parentGridColumnItem );
119+ } else {
120+ $ beforeContainerPreviewIsRendered = new BeforeContainerPreviewIsRenderedEvent ($ container , $ view , $ grid , $ parentGridColumnItem );
121+ }
105122 $ this ->eventDispatcher ->dispatch ($ beforeContainerPreviewIsRendered );
106123 $ rendered = $ view ->render ();
107124 return $ rendered ;
0 commit comments