You are here

public function HabitatSubscriber::ensureModulesDisabled in Habitat 8

1 call to HabitatSubscriber::ensureModulesDisabled()
HabitatSubscriber::ensureHabitat in src/EventSubscriber/HabitatSubscriber.php

File

src/EventSubscriber/HabitatSubscriber.php, line 26
Contains \Drupal\habitat\EventSubscriber\HabitatSubscriber.

Class

HabitatSubscriber

Namespace

Drupal\habitat\EventSubscriber

Code

public function ensureModulesDisabled($habitat) {
  $uninstalled_modules = \Drupal::config('habitat.settings')
    ->get('habitat_uninstall_' . $habitat);
  if (count($uninstalled_modules)) {
    $module_installer = \Drupal::service('module_installer');
    foreach ($uninstalled_modules as $module) {
      if (\Drupal::moduleHandler()
        ->moduleExists($module)) {
        $module_installer
          ->uninstall(array(
          $module,
        ));
        \Drupal::logger('habitat')
          ->info('%module was uninstalled for the %habitat habitat', array(
          '%module' => $module,
          '%habitat' => $habitat,
        ));
      }
    }
  }
}