You are here

function module_blacklist_requirements in Module Blacklist 8

Implements hook_requirements().

File

./module_blacklist.install, line 36
Install, update and uninstall functions for the Module Blacklist module.

Code

function module_blacklist_requirements($phase) {
  if ($phase !== 'install') {
    return [];
  }
  $blacklisted_modules = Settings::get('module_blacklist');
  if (!$blacklisted_modules) {
    return [];
  }
  $enabled_modules = array_keys(\Drupal::moduleHandler()
    ->getModuleList());
  $blacklisted_modules_enabled = array_intersect($enabled_modules, $blacklisted_modules);
  if (!$blacklisted_modules_enabled) {
    return [];
  }
  $requirements = [
    'blacklisted_modules_discovery' => [
      'description' => t('You need to uninstall the blacklisted module(s) @modules before installing Module Blacklist.', [
        '@modules' => implode(',', $blacklisted_modules_enabled),
      ]),
      'severity' => REQUIREMENT_ERROR,
    ],
  ];
  return $requirements;
}