public function EnabledModulesSensorPlugin::updateModuleListSubmit in Monitoring 8
Updates the module selection and override user input.
File
- src/
Plugin/ monitoring/ SensorPlugin/ EnabledModulesSensorPlugin.php, line 237 - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\EnabledModulesSensorPlugin.
Class
- EnabledModulesSensorPlugin
- Monitors installed modules.
Namespace
Drupal\monitoring\Plugin\monitoring\SensorPluginCode
public function updateModuleListSubmit(array &$form, FormStateInterface $form_state) {
// Get the installed module list.
$enabled_modules = Drupal::moduleHandler()
->getModuleList();
// Reduce to the module name only.
$default_value = array_combine(array_keys($enabled_modules), array_keys($enabled_modules));
// Override the current input values to the default configuration.
$user_input = $form_state
->getUserInput();
$user_input['settings']['modules'] = $default_value;
$form_state
->setUserInput($user_input);
$entity = $form_state
->getFormObject()
->getEntity();
$entity->settings['modules'] = $default_value;
$form_state
->setRebuild(TRUE);
$this
->messenger()
->addMessage(t('Module list updateed, Save to confirm.'));
}