@@ -199,20 +199,36 @@ 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+ // Cache commonly used container calls
203+ $ container = $ this ->phpbb_container ;
204+ $ path_helper = $ container ->get ('path_helper ' );
205+ $ filesystem = $ container ->get ('filesystem ' );
206+ $ cache_dir = $ container ->getParameter ('core.cache_dir ' );
207+ $ ext_manager = $ container ->get ('ext.manager ' );
208+
209+ $ is_phpbb_4 = defined ('PHPBB_VERSION ' ) &&
210+ phpbb_version_compare (PHPBB_VERSION , '4.0.0-dev ' , '>= ' );
211+
212+ $ args = $ is_phpbb_4
213+ ? [
214+ $ container ->get ('assets.bag ' ),
215+ $ config ,
216+ $ filesystem ,
217+ $ path_helper ,
218+ $ cache_dir ,
219+ $ ext_manager ,
220+ new loader ()
221+ ]
222+ : [
223+ $ config ,
224+ $ filesystem ,
225+ $ path_helper ,
226+ $ cache_dir ,
227+ $ ext_manager ,
228+ new loader (new filesystem ())
229+ ];
230+
231+ $ environment = new environment (...$ args );
216232
217233 // Custom filter for use by packager to decode greater/less than symbols
218234 $ filter = new \Twig \TwigFilter ('skeleton_decode ' , function ($ string ) {
@@ -225,8 +241,8 @@ protected function get_template_engine()
225241 $ config ,
226242 new context (),
227243 $ environment ,
228- $ this -> phpbb_container -> getParameter ( ' core. cache_dir' ) ,
229- $ this -> phpbb_container ->get ('user ' ),
244+ $ cache_dir ,
245+ $ container ->get ('user ' ),
230246 [
231247 new skeleton_version_compare ()
232248 ]
0 commit comments