public function PurgeConfigurationsConfirmForm::submitForm in Easy Install 8.10
Same name and namespace in other branches
- 8.9 src/Form/PurgeConfigurationsConfirmForm.php \Drupal\easy_install\Form\PurgeConfigurationsConfirmForm::submitForm()
- 8.5 src/Form/PurgeConfigurationsConfirmForm.php \Drupal\easy_install\Form\PurgeConfigurationsConfirmForm::submitForm()
- 8.6 src/Form/PurgeConfigurationsConfirmForm.php \Drupal\easy_install\Form\PurgeConfigurationsConfirmForm::submitForm()
- 8.7 src/Form/PurgeConfigurationsConfirmForm.php \Drupal\easy_install\Form\PurgeConfigurationsConfirmForm::submitForm()
- 8.8 src/Form/PurgeConfigurationsConfirmForm.php \Drupal\easy_install\Form\PurgeConfigurationsConfirmForm::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/ PurgeConfigurationsConfirmForm.php, line 226
Class
- PurgeConfigurationsConfirmForm
- Builds a confirmation form to uninstall selected modules.
Namespace
Drupal\easy_install\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Get the current user and to get the config that are selected.
$account = $this
->currentUser()
->id();
$ins_configs = $form_state
->getValue('configs') ? $form_state
->getValue('configs') : [];
if ($form_state
->getValue('ins_all_configs') != 0) {
foreach ($ins_configs as $key => $value) {
\Drupal::configFactory()
->getEditable($key)
->delete();
}
}
else {
foreach ($ins_configs as $key => $values) {
if ($values !== 0) {
\Drupal::configFactory()
->getEditable($key)
->delete();
}
}
}
// Get the user selected configs in optional folder and delete.
$opt_configs = $form_state
->getValue('opt_configs') ? $form_state
->getValue('opt_configs') : [];
if ($form_state
->getValue('opt_all_configs') != 0) {
foreach ($opt_configs as $key => $value) {
\Drupal::configFactory()
->getEditable($key)
->delete();
}
}
else {
foreach ($opt_configs as $key => $values) {
if ($values !== 0) {
\Drupal::configFactory()
->getEditable($key)
->delete();
}
}
}
// Delete the keyvalue of current user.
$this->keyValueExpirable
->delete($account);
$this
->messenger()
->addMessage($this
->t('The selected configurations have
been deleted.'));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}