5295737695452a839b3a445825f894294a7ef6b2
[yaffs-website] / FieldWidgetDisplayBase.php
1 <?php
2
3 namespace Drupal\entity_browser;
4
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Form\FormStateInterface;
7 use Drupal\Core\Plugin\PluginBase;
8
9 /**
10  * Base implementation for field widget display plugins.
11  */
12 abstract class FieldWidgetDisplayBase extends PluginBase implements FieldWidgetDisplayInterface {
13
14   /**
15    * Constructs field widget display plugin.
16    *
17    * @param array $configuration
18    *   A configuration array containing information about the plugin instance.
19    * @param string $plugin_id
20    *   The plugin_id for the plugin instance.
21    * @param mixed $plugin_definition
22    *   The plugin implementation definition.
23    */
24   public function __construct(array $configuration, $plugin_id, $plugin_definition) {
25     parent::__construct($configuration, $plugin_id, $plugin_definition);
26     $this->setConfiguration($configuration);
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function settingsForm(array $form, FormStateInterface $form_state) {
33     return [];
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function isApplicable(EntityTypeInterface $entity_type) {
40     return TRUE;
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function getConfiguration() {
47     return $this->configuration;
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function setConfiguration(array $configuration) {
54     $configuration += $this->defaultConfiguration();
55
56     $this->configuration = $configuration;
57   }
58
59   /**
60    * {@inheritdoc}
61    */
62   public function calculateDependencies() {
63     return [];
64   }
65
66   /**
67    * {@inheritdoc}
68    */
69   public function defaultConfiguration() {
70     return [];
71   }
72
73 }