Added missing modules, including some as submodules.
[yaffs-website] / web / modules / contrib / linkit / src / MatcherBase.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\linkit\MatcherBase.
6  */
7
8 namespace Drupal\linkit;
9
10 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
11 use Drupal\Core\Plugin\PluginBase;
12
13 /**
14  * Provides a base class for matchers.
15  *
16  * @see plugin_api
17  */
18 abstract class MatcherBase extends PluginBase implements MatcherInterface, ContainerFactoryPluginInterface {
19
20   /**
21    * The matcher ID.
22    *
23    * @var string
24    */
25   protected $uuid;
26
27   /**
28    * The weight of the matcher compared to others in a matcher collection.
29    *
30    * @var int
31    */
32   protected $weight = 0;
33
34   /**
35    * {@inheritdoc}
36    */
37   public function __construct(array $configuration, $plugin_id, $plugin_definition) {
38     parent::__construct($configuration, $plugin_id, $plugin_definition);
39
40     $this->setConfiguration($configuration);
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function getUuid() {
47     return $this->uuid;
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function getLabel() {
54     return $this->pluginDefinition['label'];
55   }
56
57   /**
58    * {@inheritdoc}
59    */
60   public function getSummary() {
61     return array();
62   }
63
64   /**
65    * {@inheritdoc}
66    */
67   public function getWeight() {
68     return $this->weight;
69   }
70
71   /**
72    * {@inheritdoc}
73    */
74   public function setWeight($weight) {
75     return $this->weight = $weight;
76   }
77
78   /**
79    * {@inheritdoc}
80    */
81   public function getConfiguration() {
82     return [
83       'uuid' => $this->getUuid(),
84       'id' => $this->getPluginId(),
85       'weight' => $this->getWeight(),
86       'settings' => $this->configuration,
87     ];
88   }
89
90   /**
91    * {@inheritdoc}
92    */
93   public function setConfiguration(array $configuration) {
94     $configuration += [
95       'uuid' => '',
96       'weight' => '0',
97       'settings' => [],
98     ];
99     $this->configuration = $configuration['settings'] + $this->defaultConfiguration();
100     $this->uuid = $configuration['uuid'];
101     $this->weight = $configuration['weight'];
102     return $this;
103   }
104
105   /**
106    * {@inheritdoc}
107    */
108   public function defaultConfiguration() {
109     return [];
110   }
111
112   /**
113    * {@inheritdoc}
114    */
115   public function calculateDependencies() {
116     return [];
117   }
118
119 }