You are here

public function CreateHtmlRouteProvider::getRoutes in Entity API 8.0

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

src/Routing/CreateHtmlRouteProvider.php, line 29
Contains \Drupal\entity\Routing\CreateHtmlRouteProvider.

Class

CreateHtmlRouteProvider
Provides HTML routes for creating entities.

Namespace

Drupal\entity\Routing

Code

public function getRoutes(EntityTypeInterface $entity_type) {
  $routes = new RouteCollection();
  if ($route = $this
    ->addPageRoute($entity_type)) {
    $routes
      ->add('entity.' . $entity_type
      ->id() . '.add_page', $route);
  }
  if ($route = $this
    ->addFormRoute($entity_type)) {
    $routes
      ->add('entity.' . $entity_type
      ->id() . '.add_form', $route);
  }
  return $routes;
}