Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Extension/ModuleInstaller.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
12 /** | 12 /** |
13 * Default implementation of the module installer. | 13 * Default implementation of the module installer. |
14 * | 14 * |
15 * It registers the module in config, installs its own configuration, | 15 * It registers the module in config, installs its own configuration, |
16 * installs the schema, updates the Drupal kernel and more. | 16 * installs the schema, updates the Drupal kernel and more. |
17 * | |
18 * We don't inject dependencies yet, as we would need to reload them after | |
19 * each installation or uninstallation of a module. | |
20 * https://www.drupal.org/project/drupal/issues/2350111 for example tries to | |
21 * solve this dilemma. | |
17 */ | 22 */ |
18 class ModuleInstaller implements ModuleInstallerInterface { | 23 class ModuleInstaller implements ModuleInstallerInterface { |
19 | 24 |
20 /** | 25 /** |
21 * The module handler. | 26 * The module handler. |
168 foreach ($current_modules as $name => $weight) { | 173 foreach ($current_modules as $name => $weight) { |
169 if (isset($current_module_filenames[$name])) { | 174 if (isset($current_module_filenames[$name])) { |
170 $module_filenames[$name] = $current_module_filenames[$name]; | 175 $module_filenames[$name] = $current_module_filenames[$name]; |
171 } | 176 } |
172 else { | 177 else { |
173 $module_path = drupal_get_path('module', $name); | 178 $module_path = \Drupal::service('extension.list.module')->getPath($name); |
174 $pathname = "$module_path/$name.info.yml"; | 179 $pathname = "$module_path/$name.info.yml"; |
175 $filename = file_exists($module_path . "/$name.module") ? "$name.module" : NULL; | 180 $filename = file_exists($module_path . "/$name.module") ? "$name.module" : NULL; |
176 $module_filenames[$name] = new Extension($this->root, 'module', $pathname, $filename); | 181 $module_filenames[$name] = new Extension($this->root, 'module', $pathname, $filename); |
177 } | 182 } |
178 } | 183 } |
184 // rebuild below. | 189 // rebuild below. |
185 $this->moduleHandler->setModuleList($module_filenames); | 190 $this->moduleHandler->setModuleList($module_filenames); |
186 $this->moduleHandler->load($module); | 191 $this->moduleHandler->load($module); |
187 module_load_install($module); | 192 module_load_install($module); |
188 | 193 |
189 // Clear the static cache of system_rebuild_module_data() to pick up the | 194 // Clear the static cache of the "extension.list.module" service to pick |
190 // new module, since it merges the installation status of modules into | 195 // up the new module, since it merges the installation status of modules |
191 // its statically cached list. | 196 // into its statically cached list. |
192 drupal_static_reset('system_rebuild_module_data'); | 197 \Drupal::service('extension.list.module')->reset(); |
193 | 198 |
194 // Update the kernel to include it. | 199 // Update the kernel to include it. |
195 $this->updateKernel($module_filenames); | 200 $this->updateKernel($module_filenames); |
196 | 201 |
197 // Replace the route provider service with a version that will rebuild | 202 // Replace the route provider service with a version that will rebuild |
343 } | 348 } |
344 | 349 |
345 if ($uninstall_dependents) { | 350 if ($uninstall_dependents) { |
346 // Add dependent modules to the list. The new modules will be processed as | 351 // Add dependent modules to the list. The new modules will be processed as |
347 // the foreach loop continues. | 352 // the foreach loop continues. |
348 $profile = drupal_get_profile(); | |
349 foreach ($module_list as $module => $value) { | 353 foreach ($module_list as $module => $value) { |
350 foreach (array_keys($module_data[$module]->required_by) as $dependent) { | 354 foreach (array_keys($module_data[$module]->required_by) as $dependent) { |
351 if (!isset($module_data[$dependent])) { | 355 if (!isset($module_data[$dependent])) { |
352 // The dependent module does not exist. | 356 // The dependent module does not exist. |
353 return FALSE; | 357 return FALSE; |
354 } | 358 } |
355 | 359 |
356 // Skip already uninstalled modules. | 360 // Skip already uninstalled modules. |
357 if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) { | 361 if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent])) { |
358 $module_list[$dependent] = $dependent; | 362 $module_list[$dependent] = $dependent; |
359 } | 363 } |
360 } | 364 } |
361 } | 365 } |
362 } | 366 } |
445 $this->moduleHandler->setModuleList($module_filenames); | 449 $this->moduleHandler->setModuleList($module_filenames); |
446 | 450 |
447 // Remove any potential cache bins provided by the module. | 451 // Remove any potential cache bins provided by the module. |
448 $this->removeCacheBins($module); | 452 $this->removeCacheBins($module); |
449 | 453 |
450 // Clear the static cache of system_rebuild_module_data() to pick up the | 454 // Clear the static cache of the "extension.list.module" service to pick |
451 // new module, since it merges the installation status of modules into | 455 // up the new module, since it merges the installation status of modules |
452 // its statically cached list. | 456 // into its statically cached list. |
453 drupal_static_reset('system_rebuild_module_data'); | 457 \Drupal::service('extension.list.module')->reset(); |
454 | 458 |
455 // Clear plugin manager caches. | 459 // Clear plugin manager caches. |
456 \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); | 460 \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); |
457 | 461 |
458 // Update the kernel to exclude the uninstalled modules. | 462 // Update the kernel to exclude the uninstalled modules. |