class RouteSubscriber in Commerce Invoice 8.2
Re-Add the route requirement for the order invoices route.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\commerce_invoice\EventSubscriber\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
EventSubscriber/ RouteSubscriber.php, line 13
Namespace
Drupal\commerce_invoice\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) {
$route = $collection
->get('entity.commerce_order.invoices');
if ($route) {
$route
->setRequirement('_invoice_order_access', 'TRUE');
$route
->setDefault('commerce_invoice_type', 'default');
}
$route = $collection
->get('entity.commerce_order.invoice_add_form');
if ($route) {
$route
->setDefault('commerce_invoice_type', 'default');
}
$route = $collection
->get('entity.commerce_invoice.canonical');
if ($route) {
$route
->setDefault('_title_callback', InvoiceController::class . '::title');
}
}
}
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 |