9ffd8c86c77a969db8737debba31f918ea3c3f47
[yaffs-website] / web / core / modules / filter / src / FilterFormatEditForm.php
1 <?php
2
3 namespace Drupal\filter;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
7
8 /**
9  * Provides a form for adding a filter format.
10  */
11 class FilterFormatEditForm extends FilterFormatFormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function form(array $form, FormStateInterface $form_state) {
17     if (!$this->entity->status()) {
18       throw new NotFoundHttpException();
19     }
20
21     $form['#title'] = $this->entity->label();
22     $form = parent::form($form, $form_state);
23     $form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($this->entity));
24     return $form;
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function submitForm(array &$form, FormStateInterface $form_state) {
31     parent::submitForm($form, $form_state);
32     drupal_set_message($this->t('The text format %format has been updated.', ['%format' => $this->entity->label()]));
33     return $this->entity;
34   }
35
36 }