protected function PurgeConfigurationsForm::buildModuleList in Easy Install 8.9
Same name and namespace in other branches
- 8.10 src/Form/PurgeConfigurationsForm.php \Drupal\easy_install\Form\PurgeConfigurationsForm::buildModuleList()
- 8.5 src/Form/PurgeConfigurationsForm.php \Drupal\easy_install\Form\PurgeConfigurationsForm::buildModuleList()
- 8.6 src/Form/PurgeConfigurationsForm.php \Drupal\easy_install\Form\PurgeConfigurationsForm::buildModuleList()
- 8.7 src/Form/PurgeConfigurationsForm.php \Drupal\easy_install\Form\PurgeConfigurationsForm::buildModuleList()
- 8.8 src/Form/PurgeConfigurationsForm.php \Drupal\easy_install\Form\PurgeConfigurationsForm::buildModuleList()
Helper function for building a list of modules to install.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array An array of modules to install and their dependencies.
1 call to PurgeConfigurationsForm::buildModuleList()
- PurgeConfigurationsForm::submitForm in src/
Form/ PurgeConfigurationsForm.php - Form submission handler.
File
- src/
Form/ PurgeConfigurationsForm.php, line 375
Class
- PurgeConfigurationsForm
- Provides module installation interface.
Namespace
Drupal\easy_install\FormCode
protected function buildModuleList(FormStateInterface $form_state) {
// Build a list of modules to install.
$modules = [
'install' => [],
'dependencies' => [],
'experimental' => [],
];
$data = system_rebuild_module_data();
foreach ($data as $name => $module) {
// If the module is installed there is nothing to do.
if ($this->moduleHandler
->moduleExists($name)) {
continue;
}
// Required modules have to be installed.
if (!empty($module->required)) {
$modules['install'][$name] = $module->info['name'];
}
elseif (($checkbox = $form_state
->getValue([
'modules',
$name,
], FALSE)) && $checkbox['enable']) {
$modules['install'][$name] = $data[$name]->info['name'];
// Identify experimental modules.
if ($data[$name]->info['package'] == 'Core (Experimental)') {
$modules['experimental'][$name] = $data[$name]->info['name'];
}
}
}
// Add all dependencies to a list.
while (list($module) = each($modules['install'])) {
foreach (array_keys($data[$module]->requires) as $dependency) {
if (!isset($modules['install'][$dependency]) && !$this->moduleHandler
->moduleExists($dependency)) {
$modules['dependencies'][$module][$dependency] = $data[$dependency]->info['name'];
$modules['install'][$dependency] = $data[$dependency]->info['name'];
// Identify experimental modules.
if ($data[$dependency]->info['package'] == 'Core (Experimental)') {
$modules['experimental'][$dependency] = $data[$dependency]->info['name'];
}
}
}
}
// Make sure the install API is available.
include_once DRUPAL_ROOT . '/core/includes/install.inc';
// Invoke hook_requirements('install'). If failures are detected, make
// sure the dependent modules aren't installed either.
foreach (array_keys($modules['install']) as $module) {
if (!drupal_check_module($module)) {
unset($modules['install'][$module]);
unset($modules['experimental'][$module]);
foreach (array_keys($data[$module]->required_by) as $dependent) {
unset($modules['install'][$dependent]);
unset($modules['dependencies'][$dependent]);
}
}
}
return $modules;
}