MatcherBase.php in Linkit 8.4
Same filename and directory in other branches
Contains \Drupal\linkit\MatcherBase.
Namespace
Drupal\linkitFile
src/MatcherBase.phpView source
<?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 [];
}
}
Classes
Name | Description |
---|---|
MatcherBase | Provides a base class for matchers. |