$config_installer = \Drupal::
service('config.installer'
);
$sync_status =
$config_installer->
isSyncing();
if ($sync_status) { $source_storage =
$config_installer->
getSourceStorage();
} $modules_installed =
[];
foreach ($module_list as $module) { $enabled =
$extension_config->
get("module.
$module"
) !== NULL;
if (!
$enabled) { // Throw an exception if the module name is too long.
if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH
) { throw new ExtensionNameLengthException("Module name '
$module' is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters'
);
} // Load a new config object for each iteration, otherwise changes made
// in hook_install() are not reflected in $extension_config.
$extension_config = \Drupal::
configFactory()->
getEditable('core.extension'
);
// Check the validity of the default configuration. This will throw
// exceptions if the configuration is not valid.
$config_installer->
checkConfigurationToInstall('module',
$module);
// Save this data without checking schema. This is a performance