123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- /**
- * @file
- * Contains \Drupal\linkit\MatcherBase.
- */
- namespace Drupal\linkit;
- use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
- use Drupal\Core\Plugin\PluginBase;
- /**
- * Provides a base class for matchers.
- *
- * @see plugin_api
- */
- abstract class MatcherBase extends PluginBase implements MatcherInterface, ContainerFactoryPluginInterface {
- /**
- * The matcher ID.
- *
- * @var string
- */
- protected $uuid;
- /**
- * The weight of the matcher compared to others in a matcher collection.
- *
- * @var int
- */
- protected $weight = 0;
- /**
- * {@inheritdoc}
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- $this->setConfiguration($configuration);
- }
- /**
- * {@inheritdoc}
- */
- public function getUuid() {
- return $this->uuid;
- }
- /**
- * {@inheritdoc}
- */
- public function getLabel() {
- return $this->pluginDefinition['label'];
- }
- /**
- * {@inheritdoc}
- */
- public function getSummary() {
- return array();
- }
- /**
- * {@inheritdoc}
- */
- public function getWeight() {
- return $this->weight;
- }
- /**
- * {@inheritdoc}
- */
- public function setWeight($weight) {
- return $this->weight = $weight;
- }
- /**
- * {@inheritdoc}
- */
- public function getConfiguration() {
- return [
- 'uuid' => $this->getUuid(),
- 'id' => $this->getPluginId(),
- 'weight' => $this->getWeight(),
- 'settings' => $this->configuration,
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function setConfiguration(array $configuration) {
- $configuration += [
- 'uuid' => '',
- 'weight' => '0',
- 'settings' => [],
- ];
- $this->configuration = $configuration['settings'] + $this->defaultConfiguration();
- $this->uuid = $configuration['uuid'];
- $this->weight = $configuration['weight'];
- return $this;
- }
- /**
- * {@inheritdoc}
- */
- public function defaultConfiguration() {
- return [];
- }
- /**
- * {@inheritdoc}
- */
- public function calculateDependencies() {
- return [];
- }
- }
|