function ModulesListConfirmForm::submitForm
Same name in other branches
- 8.9.x core/modules/system/src/Form/ModulesListConfirmForm.php \Drupal\system\Form\ModulesListConfirmForm::submitForm()
- 10 core/modules/system/src/Form/ModulesListConfirmForm.php \Drupal\system\Form\ModulesListConfirmForm::submitForm()
- 11.x core/modules/system/src/Form/ModulesListConfirmForm.php \Drupal\system\Form\ModulesListConfirmForm::submitForm()
Overrides FormInterface::submitForm
File
-
core/
modules/ system/ src/ Form/ ModulesListConfirmForm.php, line 163
Class
- ModulesListConfirmForm
- Builds a confirmation form for enabling modules with dependencies.
Namespace
Drupal\system\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Remove the key value store entry.
$account = $this->currentUser()
->id();
$this->keyValueExpirable
->delete($account);
if (!empty($this->modules['install'])) {
// Don't catch the exception that this can throw for missing dependencies:
// the form doesn't allow modules with unmet dependencies, so the only way
// this can happen is if the filesystem changed between form display and
// submit, in which case the user has bigger problems.
try {
// Install the given modules.
$this->moduleInstaller
->install(array_keys($this->modules['install']));
} catch (PreExistingConfigException $e) {
$this->messenger()
->addError($this->modulesFailToEnableMessage($this->modules, $e));
return;
} catch (UnmetDependenciesException $e) {
$this->messenger()
->addError($e->getTranslatedMessage($this->getStringTranslation(), $this->modules['install'][$e->getExtension()]));
return;
}
// Unset the messenger to make sure that we'll get the service from the
// new container.
$this->messenger = NULL;
$this->messenger()
->addStatus($this->modulesEnabledConfirmationMessage($this->modules['install']));
}
$form_state->setRedirectUrl($this->getCancelUrl());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.