function module_blacklist_module_preinstall in Module Blacklist 8
Implements hook_module_preinstall().
File
- ./
module_blacklist.module, line 15 - Module Blacklist implementation of hooks.
Code
function module_blacklist_module_preinstall($module) {
// Allow Drush if config is TRUE.
if (PHP_SAPI === 'cli' && Settings::get('module_blacklist_drush', FALSE)) {
return;
}
$module_blacklist = Settings::get('module_blacklist');
if (!$module_blacklist || !in_array($module, $module_blacklist)) {
return;
}
// Before Drupal invokes the hook hook_module_preinstall() the method
// install() at Drupal\Core\Extension\ModuleInstaller performs some tasks
// changing the configs and system files data from the module that is being
// installed, so, before throw the exception it is necessary performs a
// rollback to those changes.
\Drupal::service('module_blacklist.module_installer')
->rollbackPreinstall($module);
throw new ModuleInstallationBlocked("Unable to install '{$module}' module. The installation of this module is blocked by Module Blacklist.");
}