You are here

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

Class

RouteSubscriber
Re-Add the route requirement for the order invoices route.

Namespace

Drupal\commerce_invoice\EventSubscriber

Code

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');
  }
}