You are here

public function HtmlRouteProvider::getRoutes in Consumers 8

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 DefaultHtmlRouteProvider::getRoutes

File

src/Entity/Routing/HtmlRouteProvider.php, line 14

Class

HtmlRouteProvider

Namespace

Drupal\consumers\Entity\Routing

Code

public function getRoutes(EntityTypeInterface $entity_type) {
  $collection = parent::getRoutes($entity_type);
  $route = new Route($entity_type
    ->getLinkTemplate('make-default-form'));
  $route
    ->addDefaults([
    '_entity_form' => 'consumer.make-default',
    '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
  ])
    ->setRequirement('_entity_access', 'consumer.update')
    ->setOption('parameters', [
    'consumer' => [
      'type' => 'entity:consumer',
    ],
  ]);
  $collection
    ->add('entity.consumer.make_default_form', $route);
  return $collection;
}