You are here

public function PagererPresetDeleteForm::submitForm in Pagerer 8

Same name and namespace in other branches
  1. 8.2 src/Form/PagererPresetDeleteForm.php \Drupal\pagerer\Form\PagererPresetDeleteForm::submitForm()

Overrides EntityDeleteFormTrait::submitForm

File

src/Form/PagererPresetDeleteForm.php, line 56

Class

PagererPresetDeleteForm
Delete a Pagerer preset.

Namespace

Drupal\pagerer\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $config = $this
    ->configFactory()
    ->getEditable('pagerer.settings');
  if ($config
    ->get('core_override_preset') == $this
    ->getEntity()
    ->id()) {
    $config
      ->set('core_override_preset', 'core')
      ->save();
    $this->elementInfoManager
      ->clearCachedDefinitions();
    $this->messenger
      ->addMessage($this
      ->t("Pager %preset_label was being used as replacement of Drupal's core pager. Drupal's core pager has been reset as main pager.", [
      '%preset_label' => $this
        ->getEntity()
        ->label(),
    ]), 'warning');
  }
}