You are here

function paranoia_remove_disabled_modules in Paranoia 8

Same name and namespace in other branches
  1. 7 paranoia.module \paranoia_remove_disabled_modules()

Disables modules based on the list in hook_paranoia_disable_modules().

2 calls to paranoia_remove_disabled_modules()
paranoia_install in ./paranoia.install
Implements hook_install().
paranoia_module_validate in ./paranoia.module
Custom validation function to make sure no banned modules were enabled.

File

./paranoia.module, line 85
Disables PHP block visibility permission and gives status error if a role has this permission. Disables the PHP module. Hides the PHP and paranoia modules from the modules page. Prevents user/1 editing which could give access to abitrary contrib…

Code

function paranoia_remove_disabled_modules() {
  $module_handler = \Drupal::moduleHandler();
  $disabled_modules = $module_handler
    ->invokeAll('paranoia_disable_modules');
  foreach ($disabled_modules as $module) {
    if ($module_handler
      ->moduleExists($module)) {
      \Drupal::messenger()
        ->addMessage(t('The module %module has been disabled as it is not allowed on this site.', [
        '%module' => $module,
      ]));
      \Drupal::service('module_installer')
        ->uninstall([
        $module,
      ]);
    }
  }
}