You are here

function module_blacklist_install in Module Blacklist 8

Implements hook_install().

File

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

Code

function module_blacklist_install() {
  if (!\Drupal::isConfigSyncing()) {
    return;
  }

  // The hook_requirements() is not automatically called during the module
  // installation by config management, so it is necessary to call it manually.
  // The requirement is to fail the installation if blacklisted modules were
  // installed before Module Blacklist.
  $requirements = \Drupal::moduleHandler()
    ->invoke('module_blacklist', 'requirements', [
    'install',
  ]);
  if (!$requirements) {
    return;
  }

  // Hard fail installation.
  $exception_message = $requirements['blacklisted_modules_discovery']['description']
    ->render();
  throw new ModuleInstallationBlocked($exception_message);
}