You are here

function _opigno_lms_update_module_disable in Opigno LMS 3.x

Module disable helper function.

1 call to _opigno_lms_update_module_disable()
opigno_lms_update_9001 in ./opigno_lms.install
Uninstall redundant modules.

File

./opigno_lms.install, line 342
Install, update and uninstall functions for the "opigno_lms" installation profile.

Code

function _opigno_lms_update_module_disable($modules) {
  $module_data = \Drupal::config('core.extension')
    ->get('module');
  foreach ($modules as $item) {
    \Drupal::database()
      ->delete('key_value')
      ->condition('collection', 'system.schema')
      ->condition('name', $item)
      ->execute();
    unset($module_data[$item]);
  }
  \Drupal::configFactory()
    ->getEditable('core.extension')
    ->set('module', $module_data)
    ->save();
  \Drupal::service('cache.config')
    ->invalidateAll();
  foreach ($modules as $item) {
    if (\Drupal::moduleHandler()
      ->moduleExists($item)) {
      \Drupal::service('module_installer')
        ->uninstall([
        $item,
      ]);
    }
  }
  drupal_flush_all_caches();
}