W3cubDocs

/Drupal 8

function hook_modules_installed

hook_modules_installed($modules)

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\ModuleHandler::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.

See also

\Drupal\Core\Extension\ModuleHandler::install()

hook_install()

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

core/lib/Drupal/Core/Extension/module.api.php, line 189
Hooks related to module and update systems.

Code

function hook_modules_installed($modules) {
  if (in_array('lousy_module', $modules)) {
    \Drupal::state()->set('mymodule.lousy_module_compatibility', TRUE);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!module.api.php/function/hook_modules_installed/8.1.x