function update_helper_checklist_modules_installed in Update helper 8
Same name and namespace in other branches
- 2.x modules/update_helper_checklist/update_helper_checklist.module \update_helper_checklist_modules_installed()
Mark all updates as successful for fresh installed module.
Implements hook_modules_installed().
Parameters
array $modules: List of installed modules.
File
- modules/
update_helper_checklist/ update_helper_checklist.module, line 108 - Update helper checklist hooks.
Code
function update_helper_checklist_modules_installed(array $modules) {
/** @var \Drupal\Core\Extension\ModuleHandler $module_handler */
$module_handler = \Drupal::service('module_handler');
$modules_checklist = [];
$module_directories = $module_handler
->getModuleDirectories();
foreach ($modules as $module_name) {
$updates_file = $module_directories[$module_name] . DIRECTORY_SEPARATOR . UpdateChecklist::$updateChecklistFileName;
if (!is_file($updates_file)) {
continue;
}
$updates_checklist = Yaml::parse(file_get_contents($updates_file));
foreach ($updates_checklist as $version_items) {
foreach ($version_items as $update_hook_name => $checklist_definition) {
if (is_array($checklist_definition)) {
if (!isset($modules_checklist[$module_name])) {
$modules_checklist[$module_name] = [];
}
$modules_checklist[$module_name][] = $update_hook_name;
}
}
}
}
if (!empty($modules_checklist)) {
\Drupal::service('update_helper_checklist.update_checklist')
->markUpdatesSuccessful($modules_checklist);
}
}