|
16 | 16 | use phpbb\config\config; |
17 | 17 | use phpbb\di\service_collection; |
18 | 18 | use phpbb\filesystem\filesystem; |
| 19 | +use phpbb\path_helper; |
19 | 20 | use phpbb\skeleton\ext; |
20 | 21 | use phpbb\skeleton\template\twig\extension\skeleton_version_compare; |
21 | 22 | use phpbb\template\context; |
@@ -115,17 +116,14 @@ public function create_extension($data) |
115 | 116 | $filesystem->remove($this->root_path . 'store/tmp-ext'); |
116 | 117 | $filesystem->mkdir($ext_path); |
117 | 118 |
|
118 | | - $phpbb31 = (bool) preg_match('/^[\D]*3\.1.*$/', $data['requirements']['phpbb_version_min']); |
119 | | - |
120 | 119 | $template = $this->get_template_engine(); |
121 | 120 | $template->set_custom_style('skeletonextension', $this->root_path . 'ext/phpbb/skeleton/skeleton'); |
122 | 121 | $template->assign_vars([ |
123 | 122 | 'COMPONENT' => $data['components'], |
124 | 123 | 'EXTENSION' => $data['extension'], |
125 | 124 | 'REQUIREMENTS' => $data['requirements'], |
126 | 125 | 'AUTHORS' => $data['authors'], |
127 | | - 'LANGUAGE' => $this->get_language_version_data($phpbb31), |
128 | | - 'S_PHPBB_31' => $phpbb31, |
| 126 | + 'LANGUAGE' => $this->get_language_version_data($data), |
129 | 127 | ]); |
130 | 128 |
|
131 | 129 | $component_data = $this->get_component_dialog_values(); |
@@ -201,11 +199,14 @@ protected function get_template_engine() |
201 | 199 | 'assets_version' => null, |
202 | 200 | ]); |
203 | 201 |
|
| 202 | + /** @var path_helper $path_helper */ |
204 | 203 | $path_helper = $this->phpbb_container->get('path_helper'); |
| 204 | + /** @var filesystem $filesystem */ |
| 205 | + $filesystem = $this->phpbb_container->get('filesystem'); |
205 | 206 | $environment = new environment( |
206 | 207 | $this->phpbb_container->get('assets.bag'), |
207 | 208 | $config, |
208 | | - $this->phpbb_container->get('filesystem'), |
| 209 | + $filesystem, |
209 | 210 | $path_helper, |
210 | 211 | $this->phpbb_container->getParameter('core.cache_dir'), |
211 | 212 | $this->phpbb_container->get('ext.manager'), |
@@ -235,19 +236,25 @@ protected function get_template_engine() |
235 | 236 | * Get an array of language class and methods depending on 3.1 or 3.2 |
236 | 237 | * compatibility, for use in the skeleton twig templates. |
237 | 238 | * |
238 | | - * @param bool $phpbb31 Is phpBB 3.1 support requested? |
| 239 | + * @param array $data Extension data |
239 | 240 | * |
240 | 241 | * @return array An array of language data |
241 | 242 | */ |
242 | | - protected function get_language_version_data($phpbb31) |
| 243 | + protected function get_language_version_data($data) |
243 | 244 | { |
| 245 | + $phpbb_31 = false; |
| 246 | + if (isset($data['requirements']['phpbb_version_min'])) |
| 247 | + { |
| 248 | + $phpbb_31 = (bool) preg_match('/^\D*3\.1.*$/', $data['requirements']['phpbb_version_min']); |
| 249 | + } |
| 250 | + |
244 | 251 | return [ |
245 | | - 'class' => $phpbb31 ? '\phpbb\user' : '\phpbb\language\language', |
246 | | - 'object' => $phpbb31 ? 'user' : 'language', |
247 | | - 'function' => $phpbb31 ? 'add_lang_ext' : 'add_lang', |
| 252 | + 'class' => $phpbb_31 ? '\phpbb\user' : '\phpbb\language\language', |
| 253 | + 'object' => $phpbb_31 ? 'user' : 'language', |
| 254 | + 'function' => $phpbb_31 ? 'add_lang_ext' : 'add_lang', |
248 | 255 | 'indent' => [ |
249 | | - 'class' => $phpbb31 ? "\t\t\t" : '', |
250 | | - 'object' => $phpbb31 ? "\t" : '', |
| 256 | + 'class' => $phpbb_31 ? "\t\t\t" : '', |
| 257 | + 'object' => $phpbb_31 ? "\t" : '', |
251 | 258 | ], |
252 | 259 | ]; |
253 | 260 | } |
|
0 commit comments