Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / editor / tests / modules / src / Plugin / Editor / UnicornEditor.php
1 <?php
2
3 namespace Drupal\editor_test\Plugin\Editor;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\editor\Entity\Editor;
7 use Drupal\editor\Plugin\EditorBase;
8
9 /**
10  * Defines a Unicorn-powered text editor for Drupal (for testing purposes).
11  *
12  * @Editor(
13  *   id = "unicorn",
14  *   label = @Translation("Unicorn Editor"),
15  *   supports_content_filtering = TRUE,
16  *   supports_inline_editing = TRUE,
17  *   is_xss_safe = FALSE,
18  *   supported_element_types = {
19  *     "textarea",
20  *     "textfield",
21  *   }
22  * )
23  */
24 class UnicornEditor extends EditorBase {
25
26   /**
27    * {@inheritdoc}
28    */
29   public function getDefaultSettings() {
30     return ['ponies_too' => TRUE];
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
37     $form['ponies_too'] = [
38       '#title' => t('Pony mode'),
39       '#type' => 'checkbox',
40       '#default_value' => TRUE,
41     ];
42     return $form;
43   }
44
45   /**
46    * {@inheritdoc}
47    */
48   public function getJSSettings(Editor $editor) {
49     $js_settings = [];
50     $settings = $editor->getSettings();
51     if ($settings['ponies_too']) {
52       $js_settings['ponyModeEnabled'] = TRUE;
53     }
54     return $js_settings;
55   }
56
57   /**
58    * {@inheritdoc}
59    */
60   public function getLibraries(Editor $editor) {
61     return [
62       'editor_test/unicorn',
63     ];
64   }
65
66 }