public function StyleswitcherStyleDeleteForm::submitForm in Style Switcher 8.2
Same name and namespace in other branches
- 3.0.x src/Form/StyleswitcherStyleDeleteForm.php \Drupal\styleswitcher\Form\StyleswitcherStyleDeleteForm::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/ StyleswitcherStyleDeleteForm.php, line 75
Class
- StyleswitcherStyleDeleteForm
- Provides a form to delete a single style.
Namespace
Drupal\styleswitcher\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$name = $this->style['name'];
$styles = styleswitcher_custom_styles();
if (isset($styles[$name]['path'])) {
unset($styles[$name]);
$this
->configFactory()
->getEditable('styleswitcher.custom_styles')
->set('styles', $styles)
->save();
$this
->messenger()
->addStatus($this
->t('The style %title has been deleted.', [
'%title' => $this->style['label'],
]));
}
else {
$this
->messenger()
->addWarning($this
->t('The blank style cannot be deleted.'));
}
$form_state
->setRedirect('styleswitcher.admin');
}