You are here

protected function RouteSubscriber::alterRoutes in Automatic Entity Label 8

Same name and namespace in other branches
  1. 8.3 src/Routing/RouteSubscriber.php \Drupal\auto_entitylabel\Routing\RouteSubscriber::alterRoutes()
  2. 8.2 src/Routing/RouteSubscriber.php \Drupal\auto_entitylabel\Routing\RouteSubscriber::alterRoutes()

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 37

Class

RouteSubscriber
Subscriber for auto_entitylabel routes.

Namespace

Drupal\auto_entitylabel\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type_id => $entity_type) {
    if ($route = $this
      ->getEntityLabelRoute($entity_type)) {
      $collection
        ->add("entity.{$entity_type_id}.auto_label", $route);
    }
  }
}