Mercurial > hg > isophonics-drupal-site
comparison core/modules/taxonomy/src/Controller/TaxonomyController.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\taxonomy\Controller; | |
4 | |
5 use Drupal\Component\Utility\Xss; | |
6 use Drupal\Core\Controller\ControllerBase; | |
7 use Drupal\taxonomy\TermInterface; | |
8 use Drupal\taxonomy\VocabularyInterface; | |
9 | |
10 /** | |
11 * Provides route responses for taxonomy.module. | |
12 */ | |
13 class TaxonomyController extends ControllerBase { | |
14 | |
15 /** | |
16 * Returns a form to add a new term to a vocabulary. | |
17 * | |
18 * @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary | |
19 * The vocabulary this term will be added to. | |
20 * | |
21 * @return array | |
22 * The taxonomy term add form. | |
23 */ | |
24 public function addForm(VocabularyInterface $taxonomy_vocabulary) { | |
25 $term = $this->entityManager()->getStorage('taxonomy_term')->create(['vid' => $taxonomy_vocabulary->id()]); | |
26 return $this->entityFormBuilder()->getForm($term); | |
27 } | |
28 | |
29 /** | |
30 * Route title callback. | |
31 * | |
32 * @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary | |
33 * The vocabulary. | |
34 * | |
35 * @return string | |
36 * The vocabulary label as a render array. | |
37 */ | |
38 public function vocabularyTitle(VocabularyInterface $taxonomy_vocabulary) { | |
39 return ['#markup' => $taxonomy_vocabulary->label(), '#allowed_tags' => Xss::getHtmlTagList()]; | |
40 } | |
41 | |
42 /** | |
43 * Route title callback. | |
44 * | |
45 * @param \Drupal\taxonomy\TermInterface $taxonomy_term | |
46 * The taxonomy term. | |
47 * | |
48 * @return array | |
49 * The term label as a render array. | |
50 */ | |
51 public function termTitle(TermInterface $taxonomy_term) { | |
52 return ['#markup' => $taxonomy_term->getName(), '#allowed_tags' => Xss::getHtmlTagList()]; | |
53 } | |
54 | |
55 } |