FilterEnableForm.php

Namespace

Drupal\filter\Form

File

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

View source
<?php

declare (strict_types=1);
namespace Drupal\filter\Form;

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

/**
 * Provides the filter format enable form.
 */
class FilterEnableForm extends EntityConfirmFormBase {
    
    /**
     * {@inheritdoc}
     */
    public function getQuestion() : TranslatableMarkup {
        return $this->t('Are you sure you want to enable the text format %format?', [
            '%format' => $this->entity
                ->label(),
        ]);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCancelUrl() : Url {
        return new Url('filter.admin_overview');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getConfirmText() : TranslatableMarkup {
        return $this->t('Enable');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDescription() : TranslatableMarkup {
        return $this->t('This will make the %format format available.', [
            '%format' => $this->entity
                ->label(),
        ]);
    }
    
    /**
     * {@inheritdoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) : void {
        $this->entity
            ->enable()
            ->save();
        $this->messenger()
            ->addMessage($this->t('Enabled text format %format.', [
            '%format' => $this->entity
                ->label(),
        ]));
        $form_state->setRedirectUrl($this->getCancelUrl());
    }

}

Classes

Title Deprecated Summary
FilterEnableForm Provides the filter format enable form.

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