class RouteSubscriber in Commerce Shipping 8.2
Re-add the route requirement for the shipment collection route.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\commerce_shipping\EventSubscriber\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
EventSubscriber/ RouteSubscriber.php, line 12
Namespace
Drupal\commerce_shipping\EventSubscriberView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
// Ensure to run after the Views route subscriber.
// @see \Drupal\views\EventSubscriber\RouteSubscriber.
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-200,
];
return $events;
}
/**
* {@inheritdoc}
*/
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');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase:: |
|
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |