You are here

public function ModuleInstallerInterface::install in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php \Drupal\Core\Extension\ModuleInstallerInterface::install()
  2. 10 core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php \Drupal\Core\Extension\ModuleInstallerInterface::install()

Installs a given list of modules.

Order of events:

  • Gather and add module dependencies to $module_list (if applicable).
  • For each module that is being installed:
  • Invoke hook_modules_installed().

To install test modules add

$settings['extension_discovery_scan_tests'] = TRUE;

to your settings.php.

Parameters

string[] $module_list: An array of module names.

bool $enable_dependencies: (optional) If TRUE, dependencies will automatically be installed in the correct order. This incurs a significant performance cost, so use FALSE if you know $module_list is already complete.

Return value

bool TRUE if the modules were successfully installed.

Throws

\Drupal\Core\Extension\MissingDependencyException Thrown when a requested module, or a dependency of one, can not be found.

\Drupal\Core\Extension\ExtensionNameLengthException Thrown when the extension's name is longer than DRUPAL_EXTENSION_NAME_MAX_LENGTH.

See also

hook_module_preinstall()

hook_install()

hook_modules_installed()

2 methods override ModuleInstallerInterface::install()
ModuleInstaller::install in core/lib/Drupal/Core/Extension/ModuleInstaller.php
Installs a given list of modules.
ModuleInstaller::install in core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php
Installs a given list of modules.

File

core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php, line 48

Class

ModuleInstallerInterface
Provides the installation of modules with creating the db schema and more.

Namespace

Drupal\Core\Extension

Code

public function install(array $module_list, $enable_dependencies = TRUE);