View source
<?php
namespace Drupal\linkit;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class MatcherBase extends PluginBase implements MatcherInterface, ContainerFactoryPluginInterface {
protected $uuid;
protected $weight = 0;
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this
->setConfiguration($configuration);
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition);
}
public function getUuid() {
return $this->uuid;
}
public function getLabel() {
return $this->pluginDefinition['label'];
}
public function getSummary() {
return [];
}
public function getWeight() {
return $this->weight;
}
public function setWeight($weight) {
return $this->weight = $weight;
}
public function getConfiguration() {
return [
'uuid' => $this
->getUuid(),
'id' => $this
->getPluginId(),
'weight' => $this
->getWeight(),
'settings' => $this->configuration,
];
}
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;
}
public function defaultConfiguration() {
return [];
}
public function calculateDependencies() {
return [];
}
}