5 * Contains \Drupal\linkit\AttributeBase.
8 namespace Drupal\linkit;
10 use Drupal\Core\Plugin\PluginBase;
13 * Provides a base class for attribute plugins.
15 * @see \Drupal\linkit\Annotation\Attribute
16 * @see \Drupal\linkit\AttributeBase
17 * @see \Drupal\linkit\AttributeManager
20 abstract class AttributeBase extends PluginBase implements AttributeInterface {
23 * The weight of the attribute compared to others in an attribute collection.
27 protected $weight = 0;
32 public function __construct(array $configuration, $plugin_id, $plugin_definition) {
33 parent::__construct($configuration, $plugin_id, $plugin_definition);
35 $this->setConfiguration($configuration);
41 public function getConfiguration() {
43 'id' => $this->getPluginId(),
44 'weight' => $this->weight,
45 'settings' => $this->configuration,
52 public function setConfiguration(array $configuration) {
57 $this->configuration = $configuration['settings'] + $this->defaultConfiguration();
58 $this->weight = $configuration['weight'];
65 public function defaultConfiguration() {
72 public function calculateDependencies() {
79 public function getLabel() {
80 return $this->pluginDefinition['label'];
86 public function getHtmlName() {
87 return $this->pluginDefinition['html_name'];
93 public function getDescription() {
94 return $this->pluginDefinition['description'];
100 public function getWeight() {
101 return $this->weight;
107 public function setWeight($weight) {
108 $this->weight = $weight;