Mercurial > hg > isophonics-drupal-site
comparison core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\taxonomy\Entity\Routing; | |
4 | |
5 use Drupal\Core\Entity\EntityTypeInterface; | |
6 use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | |
7 use Symfony\Component\Routing\Route; | |
8 | |
9 class VocabularyRouteProvider extends AdminHtmlRouteProvider { | |
10 | |
11 /** | |
12 * {@inheritdoc} | |
13 */ | |
14 public function getRoutes(EntityTypeInterface $entity_type) { | |
15 | |
16 $collection = parent::getRoutes($entity_type); | |
17 | |
18 if ($reset_page_route = $this->getResetPageRoute($entity_type)) { | |
19 $collection->add("entity.taxonomy_vocabulary.reset_form", $reset_page_route); | |
20 } | |
21 | |
22 if ($overview_page_route = $this->getOverviewPageRoute($entity_type)) { | |
23 $collection->add("entity.taxonomy_vocabulary.overview_form", $overview_page_route); | |
24 } | |
25 | |
26 return $collection; | |
27 } | |
28 | |
29 /** | |
30 * {@inheritdoc} | |
31 */ | |
32 protected function getCollectionRoute(EntityTypeInterface $entity_type) { | |
33 if ($route = parent::getCollectionRoute($entity_type)) { | |
34 $route->setRequirement('_permission', 'access taxonomy overview+administer taxonomy'); | |
35 return $route; | |
36 } | |
37 } | |
38 | |
39 /** | |
40 * Gets the reset page route. | |
41 * | |
42 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | |
43 * The entity type. | |
44 * | |
45 * @return \Symfony\Component\Routing\Route|null | |
46 * The generated route, if available. | |
47 */ | |
48 protected function getResetPageRoute(EntityTypeInterface $entity_type) { | |
49 $route = new Route('/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/reset'); | |
50 $route->setDefault('_entity_form', 'taxonomy_vocabulary.reset'); | |
51 $route->setDefault('_title', 'Reset'); | |
52 $route->setRequirement('_permission', $entity_type->getAdminPermission()); | |
53 $route->setOption('_admin_route', TRUE); | |
54 | |
55 return $route; | |
56 } | |
57 | |
58 /** | |
59 * Gets the overview page route. | |
60 * | |
61 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | |
62 * The entity type. | |
63 * | |
64 * @return \Symfony\Component\Routing\Route|null | |
65 * The generated route, if available. | |
66 */ | |
67 protected function getOverviewPageRoute(EntityTypeInterface $entity_type) { | |
68 $route = new Route('/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview'); | |
69 $route->setDefault('_title_callback', 'Drupal\taxonomy\Controller\TaxonomyController::vocabularyTitle'); | |
70 $route->setDefault('_form', 'Drupal\taxonomy\Form\OverviewTerms'); | |
71 $route->setRequirement('_entity_access', 'taxonomy_vocabulary.access taxonomy overview'); | |
72 $route->setOption('_admin_route', TRUE); | |
73 | |
74 return $route; | |
75 } | |
76 | |
77 } |