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