annotate core/modules/taxonomy/src/Entity/Routing/VocabularyRouteProvider.php @ 19:fa3358dc1485 tip

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