22
33namespace Visol \Handlebars \ViewHelpers ;
44
5+ use Psr \Http \Message \ServerRequestInterface ;
56use TYPO3 \CMS \Core \Utility \GeneralUtility ;
67use TYPO3Fluid \Fluid \Core \ViewHelper \AbstractViewHelper ;
78use Visol \Handlebars \Rendering \HandlebarsContext ;
@@ -70,17 +71,17 @@ public function initializeArguments(): void
7071 $ this ->registerArgument ('settings ' , 'array ' , '' , false , []);
7172 $ this ->registerArgument ('data ' , 'array ' , '' , false , []);
7273 }
73-
74+
7475 public function render (): string
7576 {
7677 $ template = $ this ->arguments ['template ' ];
7778 $ settings = $ this ->arguments ['settings ' ];
7879 $ data = $ this ->arguments ['data ' ];
79-
80+
8081 $ handlebarsView = GeneralUtility::makeInstance (HandlebarsView::class);
8182 $ handlebarsRenderingContext = GeneralUtility::makeInstance (
8283 HandlebarsContext::class,
83- $ this ->renderingContext ->getRequest ( )
84+ $ this ->renderingContext ->getAttribute (ServerRequestInterface::class )
8485 );
8586 $ handlebarsView ->setRenderingContext ($ handlebarsRenderingContext );
8687
@@ -89,9 +90,9 @@ public function render(): string
8990 } else {
9091 $ settings = [];
9192 }
92-
93+
9394 $ settings = array_replace_recursive ($ settings , [
94- 'templatesRootPath ' => $ settings ['templatesRootPath ' ],
95+ 'templatesRootPath ' => $ settings ['templatesRootPath ' ] ?? null ,
9596 'template ' => $ template ,
9697 'additionalData ' => $ data
9798 ]);
0 commit comments