FilterFormatEditForm.php 1 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\filter\FilterFormatEditForm.
6 7 8 9
 */

namespace Drupal\filter;

10
use Drupal\Core\Form\FormStateInterface;
11 12 13
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
14
 * Provides a form for adding a filter format.
15
 */
16
class FilterFormatEditForm extends FilterFormatFormBase {
17 18 19 20

  /**
   * {@inheritdoc}
   */
21
  public function form(array $form, FormStateInterface $form_state) {
22 23 24 25
    if (!$this->entity->status()) {
      throw new NotFoundHttpException();
    }

26
    $form['#title'] = $this->entity->label();
27 28 29 30 31 32 33 34
    $form = parent::form($form, $form_state);
    $form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($this->entity));
    return $form;
  }

  /**
   * {@inheritdoc}
   */
35 36
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
37
    drupal_set_message($this->t('The text format %format has been updated.', array('%format' => $this->entity->label())));
38 39 40 41
    return $this->entity;
  }

}