@@ -199,20 +199,35 @@ protected function get_template_engine()
199199 'assets_version ' => null ,
200200 ]);
201201
202- /** @var path_helper $path_helper */
203- $ path_helper = $ this ->phpbb_container ->get ('path_helper ' );
204- /** @var filesystem $filesystem */
205- $ filesystem = $ this ->phpbb_container ->get ('filesystem ' );
206- $ environment = new environment (
207- $ config ,
208- $ filesystem ,
209- $ path_helper ,
210- $ this ->phpbb_container ->getParameter ('core.cache_dir ' ),
211- $ this ->phpbb_container ->get ('ext.manager ' ),
212- new loader (
213- new filesystem ()
214- )
215- );
202+ $ container = $ this ->phpbb_container ;
203+ $ path_helper = $ container ->get ('path_helper ' );
204+ $ filesystem = $ container ->get ('filesystem ' );
205+ $ cache_dir = $ container ->getParameter ('core.cache_dir ' );
206+ $ ext_manager = $ container ->get ('ext.manager ' );
207+
208+ $ is_phpbb_4 = defined ('PHPBB_VERSION ' ) &&
209+ phpbb_version_compare (PHPBB_VERSION , '4.0.0-dev ' , '>= ' );
210+
211+ $ args = $ is_phpbb_4
212+ ? [
213+ $ container ->get ('assets.bag ' ),
214+ $ config ,
215+ $ filesystem ,
216+ $ path_helper ,
217+ $ cache_dir ,
218+ $ ext_manager ,
219+ new loader ()
220+ ]
221+ : [
222+ $ config ,
223+ $ filesystem ,
224+ $ path_helper ,
225+ $ cache_dir ,
226+ $ ext_manager ,
227+ new loader (new filesystem ())
228+ ];
229+
230+ $ environment = new environment (...$ args );
216231
217232 // Custom filter for use by packager to decode greater/less than symbols
218233 $ filter = new \Twig \TwigFilter ('skeleton_decode ' , function ($ string ) {
@@ -225,8 +240,8 @@ protected function get_template_engine()
225240 $ config ,
226241 new context (),
227242 $ environment ,
228- $ this -> phpbb_container -> getParameter ( ' core. cache_dir' ) ,
229- $ this -> phpbb_container ->get ('user ' ),
243+ $ cache_dir ,
244+ $ container ->get ('user ' ),
230245 [
231246 new skeleton_version_compare ()
232247 ]
0 commit comments