X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Flinkit%2Fsrc%2FEntity%2FProfile.php;fp=web%2Fmodules%2Fcontrib%2Flinkit%2Fsrc%2FEntity%2FProfile.php;h=785ff6365a8b55dafed8591a778e68165a77930e;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/linkit/src/Entity/Profile.php b/web/modules/contrib/linkit/src/Entity/Profile.php new file mode 100644 index 000000000..785ff6365 --- /dev/null +++ b/web/modules/contrib/linkit/src/Entity/Profile.php @@ -0,0 +1,252 @@ +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'); + } + +}