3 namespace Drupal\taxonomy\Controller;
5 use Drupal\Component\Utility\Xss;
6 use Drupal\Core\Controller\ControllerBase;
7 use Drupal\taxonomy\TermInterface;
8 use Drupal\taxonomy\VocabularyInterface;
11 * Provides route responses for taxonomy.module.
13 class TaxonomyController extends ControllerBase {
16 * Returns a form to add a new term to a vocabulary.
18 * @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary
19 * The vocabulary this term will be added to.
22 * The taxonomy term add form.
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);
30 * Route title callback.
32 * @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary
36 * The vocabulary label as a render array.
38 public function vocabularyTitle(VocabularyInterface $taxonomy_vocabulary) {
39 return ['#markup' => $taxonomy_vocabulary->label(), '#allowed_tags' => Xss::getHtmlTagList()];
43 * Route title callback.
45 * @param \Drupal\taxonomy\TermInterface $taxonomy_term
49 * The term label as a render array.
51 public function termTitle(TermInterface $taxonomy_term) {
52 return ['#markup' => $taxonomy_term->getName(), '#allowed_tags' => Xss::getHtmlTagList()];