Version 1
[yaffs-website] / web / core / modules / editor / src / Plugin / EditorBase.php
1 <?php
2
3 namespace Drupal\editor\Plugin;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\Plugin\PluginBase;
7 use Drupal\editor\Entity\Editor;
8
9 /**
10  * Defines a base class from which other modules providing editors may extend.
11  *
12  * This class provides default implementations of the EditorPluginInterface so
13  * that classes extending this one do not need to implement every method.
14  *
15  * Plugins extending this class need to specify an annotation containing the
16  * plugin definition so the plugin can be discovered.
17  *
18  * @see \Drupal\editor\Annotation\Editor
19  * @see \Drupal\editor\Plugin\EditorPluginInterface
20  * @see \Drupal\editor\Plugin\EditorManager
21  * @see plugin_api
22  */
23 abstract class EditorBase extends PluginBase implements EditorPluginInterface {
24
25   /**
26    * {@inheritdoc}
27    */
28   public function getDefaultSettings() {
29     return [];
30   }
31
32   /**
33    * {@inheritdoc}
34    *
35    * @todo Remove in Drupal 9.0.0.
36    */
37   public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
38     @trigger_error('The ' . __METHOD__ . ' method is deprecated since version 8.3.x and will be removed in 9.0.0.', E_USER_DEPRECATED);
39     return $form;
40   }
41
42   /**
43    * {@inheritdoc}
44    *
45    * @todo Remove in Drupal 9.0.0.
46    */
47   public function settingsFormValidate(array $form, FormStateInterface $form_state) {
48     @trigger_error('The ' . __METHOD__ . ' method is deprecated since version 8.3.x and will be removed in 9.0.0.', E_USER_DEPRECATED);
49   }
50
51   /**
52    * {@inheritdoc}
53    *
54    * @todo Remove in Drupal 9.0.0.
55    */
56   public function settingsFormSubmit(array $form, FormStateInterface $form_state) {
57     @trigger_error('The ' . __METHOD__ . ' method is deprecated since version 8.3.x and will be removed in 9.0.0.', E_USER_DEPRECATED);
58   }
59
60   /**
61    * {@inheritdoc}
62    */
63   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
64     return $this->settingsForm($form, $form_state, $form_state->get('editor'));
65   }
66
67   /**
68    * {@inheritdoc}
69    */
70   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
71     return $this->settingsFormValidate($form, $form_state);
72   }
73
74   /**
75    * {@inheritdoc}
76    */
77   public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
78     return $this->settingsFormSubmit($form, $form_state);
79   }
80
81 }