Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / linkit / src / Plugin / Linkit / Matcher / TermMatcher.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\linkit\Plugin\Linkit\Matcher\TermMatcher.
6  */
7
8 namespace Drupal\linkit\Plugin\Linkit\Matcher;
9
10 use Drupal\Core\Form\FormStateInterface;
11 use Drupal\linkit\Utility\LinkitXss;
12
13 /**
14  * @Matcher(
15  *   id = "entity:taxonomy_term",
16  *   target_entity = "taxonomy_term",
17  *   label = @Translation("Taxonomy term"),
18  *   provider = "taxonomy"
19  * )
20  */
21 class TermMatcher extends EntityMatcher {
22
23   /**
24    * {@inheritdoc}
25    */
26   public function calculateDependencies() {
27     return parent::calculateDependencies() + [
28       'module' => ['taxonomy'],
29     ];
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
36     $form = parent::buildConfigurationForm($form, $form_state);
37     $this->insertTokenList($form, ['term']);
38     return $form;
39   }
40
41   /**
42    * {@inheritdoc}
43    */
44   protected function buildDescription($entity) {
45     $description = \Drupal::token()->replace($this->configuration['result_description'], ['term' => $entity], []);
46     return LinkitXss::descriptionFilter($description);
47   }
48
49 }