You are here

protected function RouteSubscriber::alterRoutes in Commerce Core 8.2

Alters existing routes for a specific collection.

Parameters

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

Overrides RouteSubscriberBase::alterRoutes

File

modules/promotion/src/EventSubscriber/RouteSubscriber.php, line 30

Class

RouteSubscriber
Provides a route subscriber that adding the _admin_route option to the routes like "promotion/%/coupons".

Namespace

Drupal\commerce_promotion\EventSubscriber

Code

protected function alterRoutes(RouteCollection $collection) {
  $route = $collection
    ->get('entity.commerce_promotion_coupon.collection');
  if ($route) {
    $route
      ->setOption('_admin_route', TRUE);
    $route
      ->setOption('parameters', [
      'commerce_promotion' => [
        'type' => 'entity:commerce_promotion',
      ],
    ]);
  }
}