FilterDisableForm.php

Same filename and directory in other branches
  1. 9 core/modules/filter/src/Form/FilterDisableForm.php
  2. 8.9.x core/modules/filter/src/Form/FilterDisableForm.php
  3. 10 core/modules/filter/src/Form/FilterDisableForm.php

Namespace

Drupal\filter\Form

File

core/modules/filter/src/Form/FilterDisableForm.php

View source
<?php

namespace Drupal\filter\Form;

use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * Provides the filter format disable form.
 *
 * @internal
 */
class FilterDisableForm extends EntityConfirmFormBase {
  
  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return $this->t('Are you sure you want to disable the text format %format?', [
      '%format' => $this->entity
        ->label(),
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return new Url('filter.admin_overview');
  }
  
  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return $this->t('Disable');
  }
  
  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this->t('Any content saved with the %format text format will not be displayed on the site until it is resaved with an enabled text format.', [
      '%format' => $this->entity
        ->label(),
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity
      ->disable()
      ->save();
    $this->messenger()
      ->addStatus($this->t('Disabled text format %format.', [
      '%format' => $this->entity
        ->label(),
    ]));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}

Classes

Title Deprecated Summary
FilterDisableForm Provides the filter format disable form.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.