You are here

protected function Updater::installModules in Update helper 8

Same name and namespace in other branches
  1. 2.x src/Updater.php \Drupal\update_helper\Updater::installModules()

Installs modules.

Parameters

array $modules: List of module names.

1 call to Updater::installModules()
Updater::executeGlobalActions in src/Updater.php
Get array with defined global actions.

File

src/Updater.php, line 241

Class

Updater
Helper class to update configuration.

Namespace

Drupal\update_helper

Code

protected function installModules(array $modules) {
  foreach ($modules as $module) {
    try {
      if ($this->moduleInstaller
        ->install([
        $module,
      ])) {
        $this
          ->logInfo($this
          ->t('Module @module is successfully enabled.', [
          '@module' => $module,
        ]));
      }
      else {
        $this
          ->logWarning($this
          ->t('Unable to enable @module.', [
          '@module' => $module,
        ]));
      }
    } catch (MissingDependencyException $e) {
      $this
        ->logWarning($this
        ->t('Unable to enable @module because of missing dependencies.', [
        '@module' => $module,
      ]));
    }
  }
}