You are here

public function DefaultHtmlRouteProvider::getRoutes in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getRoutes()

Provides routes for entities.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type

Return value

\Symfony\Component\Routing\RouteCollection|\Symfony\Component\Routing\Route[] Returns a route collection or an array of routes keyed by name, like route_callbacks inside 'routing.yml' files.

Overrides EntityRouteProviderInterface::getRoutes

File

core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php, line 62
Contains \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider.

Class

DefaultHtmlRouteProvider
Provides HTML routes for entities.

Namespace

Drupal\Core\Entity\Routing

Code

public function getRoutes(EntityTypeInterface $entity_type) {
  $collection = new RouteCollection();
  $entity_type_id = $entity_type
    ->id();
  if ($edit_route = $this
    ->getEditFormRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.edit_form", $edit_route);
  }
  if ($canonical_route = $this
    ->getCanonicalRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.canonical", $canonical_route);
  }
  if ($delete_route = $this
    ->getDeleteFormRoute($entity_type)) {
    $collection
      ->add("entity.{$entity_type_id}.delete_form", $delete_route);
  }
  return $collection;
}