You are here

public function RouteSubscriber::afterPageManagerRoutes in Page Manager 8

Same name and namespace in other branches
  1. 8.4 tests/modules/page_manager_routing_test/src/Routing/RouteSubscriber.php \Drupal\page_manager_routing_test\Routing\RouteSubscriber::afterPageManagerRoutes()

Alters the existing route collection.

Parameters

\Drupal\Core\Routing\RouteBuildEvent $event: The route build event.

File

tests/modules/page_manager_routing_test/src/Routing/RouteSubscriber.php, line 34

Class

RouteSubscriber
Route subscriber for Page Manager Routing Test.

Namespace

Drupal\page_manager_routing_test\Routing

Code

public function afterPageManagerRoutes(RouteBuildEvent $event) {
  $collection = $event
    ->getRouteCollection();
  if ($original_route = $collection
    ->get('entity.entity_test.canonical')) {
    $route = new Route($original_route
      ->getPath(), $original_route
      ->getDefaults(), $original_route
      ->getRequirements(), $original_route
      ->getOptions());
    $route
      ->setRequirement('_format', 'json');
    $collection
      ->add('entity.entity_test.canonical.json', $route);
  }
}