function hook_modules_installed
Same name in other branches
- 7.x modules/system/system.api.php \hook_modules_installed()
- 8.9.x core/lib/Drupal/Core/Extension/module.api.php \hook_modules_installed()
- 10 core/lib/Drupal/Core/Extension/module.api.php \hook_modules_installed()
- 11.x core/lib/Drupal/Core/Extension/module.api.php \hook_modules_installed()
Perform necessary actions after modules are installed.
This function differs from hook_install() in that it gives all other modules a chance to perform actions when a module is installed, whereas hook_install() is only called on the module actually being installed. See \Drupal\Core\Extension\ModuleInstaller::install() for a detailed description of the order in which install hooks are invoked.
This hook should be implemented in a .module file, not in an .install file.
Parameters
$modules: An array of the modules that were installed.
bool $is_syncing: TRUE if the module is being installed as part of a configuration import. In these cases, your hook implementation needs to carefully consider what changes, if any, it should make. For example, it should not make any changes to configuration objects or configuration entities. Those changes should be made earlier and exported so during import there's no need to do them again.
See also
\Drupal\Core\Extension\ModuleInstaller::install()
Related topics
11 functions implement hook_modules_installed()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- block_modules_installed in core/
modules/ block/ block.module - Implements hook_modules_installed().
- help_topics_modules_installed in core/
modules/ help_topics/ help_topics.module - Implements hook_modules_installed().
- jsonapi_modules_installed in core/
modules/ jsonapi/ jsonapi.module - Implements hook_modules_installed().
- language_modules_installed in core/
modules/ language/ language.module - Implements hook_modules_installed().
- locale_modules_installed in core/
modules/ locale/ locale.module - Implements hook_modules_installed().
1 invocation of hook_modules_installed()
- ModuleInstaller::install in core/
lib/ Drupal/ Core/ Extension/ ModuleInstaller.php - Installs a given list of modules.
File
-
core/
lib/ Drupal/ Core/ Extension/ module.api.php, line 193
Code
function hook_modules_installed($modules, $is_syncing) {
if (in_array('lousy_module', $modules)) {
\Drupal::state()->set('mymodule.lousy_module_compatibility', TRUE);
}
if (!$is_syncing) {
\Drupal::service('mymodule.service')->doSomething($modules);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.