1515
1616use phpbb \config \config ;
1717use phpbb \di \service_collection ;
18- use phpbb \path_helper ;
1918use phpbb \template \context ;
19+ use phpbb \template \twig \environment ;
20+ use phpbb \template \twig \loader ;
2021use phpbb \template \twig \twig ;
2122use phpbb \user ;
23+ use Symfony \Component \DependencyInjection \ContainerInterface ;
2224use Symfony \Component \Filesystem \Filesystem ;
2325use Symfony \Component \Finder \Finder ;
2426
@@ -29,8 +31,8 @@ class packager
2931 /** @var user */
3032 protected $ user ;
3133
32- /** @var path_helper */
33- protected $ path_helper ;
34+ /** @var ContainerInterface */
35+ protected $ phpbb_container ;
3436
3537 /** @var service_collection */
3638 protected $ collection ;
@@ -39,14 +41,14 @@ class packager
3941 * Constructor
4042 *
4143 * @param user $user User instance (mostly for translation)
42- * @param path_helper $path_helper The filesystem object
44+ * @param ContainerInterface $phpbb_container
4345 * @param service_collection $collection
4446 * @param string $root_path
4547 */
46- public function __construct (user $ user , path_helper $ path_helper , service_collection $ collection , $ root_path )
48+ public function __construct (user $ user , ContainerInterface $ phpbb_container , service_collection $ collection , $ root_path )
4749 {
4850 $ this ->user = $ user ;
49- $ this ->path_helper = $ path_helper ;
51+ $ this ->phpbb_container = $ phpbb_container ;
5052 $ this ->collection = $ collection ;
5153 $ this ->root_path = $ root_path ;
5254 }
@@ -109,11 +111,43 @@ public function create_extension($data)
109111 $ filesystem ->remove ($ this ->root_path . 'store/tmp-ext ' );
110112 $ filesystem ->mkdir ($ ext_path );
111113
112- $ template_engine = new twig ( $ this -> path_helper , new config (array (
114+ $ config = new config (array (
113115 'load_tplcompile ' => true ,
114116 'tpl_allow_php ' => false ,
115117 'assets_version ' => null ,
116- )), $ this ->user , new context ());
118+ ));
119+
120+ if (phpbb_version_compare (PHPBB_VERSION , '3.2.0-dev ' , '< ' ))
121+ {
122+ $ template_engine = new twig (
123+ $ this ->phpbb_container ->get ('path_helper ' ),
124+ $ config ,
125+ $ this ->user ,
126+ new context ()
127+ );
128+ }
129+ else
130+ {
131+ $ template_engine = new twig (
132+ $ this ->phpbb_container ->get ('path_helper ' ),
133+ $ config ,
134+ new context (),
135+ new environment (
136+ $ config ,
137+ $ this ->phpbb_container ->get ('filesystem ' ),
138+ $ this ->phpbb_container ->get ('path_helper ' ),
139+ $ this ->phpbb_container ,
140+ $ this ->phpbb_container ->getParameter ('core.cache_dir ' ),
141+ $ this ->phpbb_container ->get ('ext.manager ' ),
142+ new loader (
143+ new \phpbb \filesystem \filesystem ()
144+ )
145+ ),
146+ $ this ->phpbb_container ->getParameter ('core.cache_dir ' ),
147+ $ this ->phpbb_container ->get ('user ' )
148+ );
149+ }
150+
117151 $ template_engine ->set_custom_style ('skeletonextension ' , $ this ->root_path . 'ext/phpbb/skeleton/skeleton ' );
118152
119153 $ template_engine ->assign_vars (array (
0 commit comments