You are here

protected function RouteSubscriber::alterRoutes in Commerce Shipping 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

src/EventSubscriber/RouteSubscriber.php, line 29

Class

RouteSubscriber
Re-add the route requirement for the shipment collection route.

Namespace

Drupal\commerce_shipping\EventSubscriber

Code

protected function alterRoutes(RouteCollection $collection) {

  // ShipmentRouteProvider sets the "_shipment_collection_access" requirement
  // to the shipment collection route but it's being removed by the route
  // subscriber provided by Views, so put it back.
  // @todo: Remove once Views will merge the route requirements.
  $route = $collection
    ->get('entity.commerce_shipment.collection');
  if ($route) {
    $route
      ->setRequirement('_shipment_collection_access', 'TRUE');
  }
}