get('description'); } /** * {@inheritdoc} */ public function setDescription($description) { $this->set('description', trim($description)); return $this; } /** * {@inheritdoc} */ public function getAttribute($attribute_id) { return $this->getAttributes()->get($attribute_id); } /** * {@inheritdoc} */ public function getAttributes() { if (!$this->attributeCollection) { $this->attributeCollection = new AttributeCollection($this->getAttributeManager(), $this->attributes); $this->attributeCollection->sort(); } return $this->attributeCollection; } /** * {@inheritdoc} */ public function addAttribute(array $configuration) { $this->getAttributes()->addInstanceId($configuration['id'], $configuration); return $configuration['id']; } /** * {@inheritdoc} */ public function removeAttribute($attribute_id) { unset($this->attributes[$attribute_id]); $this->getAttributes()->removeInstanceId($attribute_id); return $this; } /** * {@inheritdoc} */ public function setAttributeConfig($attribute_id, array $configuration) { $this->attributes[$attribute_id] = $configuration; $this->getAttributes()->setInstanceConfiguration($attribute_id, $configuration); return $this; } /** * {@inheritdoc} */ public function getMatcher($instance_id) { return $this->getMatchers()->get($instance_id); } /** * {@inheritdoc} */ public function getMatchers() { if (!$this->matcherCollection) { $this->matcherCollection = new MatcherCollection($this->getMatcherManager(), $this->matchers); $this->matcherCollection->sort(); } return $this->matcherCollection; } /** * {@inheritdoc} */ public function addMatcher(array $configuration) { $configuration['uuid'] = $this->uuidGenerator()->generate(); $this->getMatchers()->addInstanceId($configuration['uuid'], $configuration); return $configuration['uuid']; } /** * {@inheritdoc} */ public function removeMatcher(MatcherInterface $matcher) { $this->getMatchers()->removeInstanceId($matcher->getUuid()); $this->save(); return $this; } /** * {@inheritdoc} */ public function setMatcherConfig($instance_id, array $configuration) { $this->matchers[$instance_id] = $configuration; $this->getMatchers()->setInstanceConfiguration($instance_id, $configuration); return $this; } /** * {@inheritdoc} */ public function getPluginCollections() { return array( 'attributes' => $this->getAttributes(), 'matchers' => $this->getMatchers(), ); } /** * Returns the attribute manager. * * @return \Drupal\Component\Plugin\PluginManagerInterface * The attribute manager. */ protected function getAttributeManager() { return \Drupal::service('plugin.manager.linkit.attribute'); } /** * Returns the matcher manager. * * @return \Drupal\Component\Plugin\PluginManagerInterface * The matcher manager. */ protected function getMatcherManager() { return \Drupal::service('plugin.manager.linkit.matcher'); } }