public function DevelReinstall::submitForm in Devel 8.2
Same name and namespace in other branches
- 8.3 src/Form/DevelReinstall.php \Drupal\devel\Form\DevelReinstall::submitForm()
- 8 src/Form/DevelReinstall.php \Drupal\devel\Form\DevelReinstall::submitForm()
- 4.x src/Form/DevelReinstall.php \Drupal\devel\Form\DevelReinstall::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ DevelReinstall.php, line 141
Class
- DevelReinstall
- Display a dropdown of installed modules with the option to reinstall them.
Namespace
Drupal\devel\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
try {
$modules = $form_state
->getValue('reinstall');
$reinstall = array_keys(array_filter($modules));
$this->moduleInstaller
->uninstall($reinstall, FALSE);
$this->moduleInstaller
->install($reinstall, FALSE);
$this
->messenger()
->addMessage($this
->t('Uninstalled and installed: %names.', [
'%names' => implode(', ', $reinstall),
]));
} catch (\Exception $e) {
$this
->messenger()
->addError($this
->t('Unable to reinstall modules. Error: %error.', [
'%error' => $e
->getMessage(),
]));
}
}