You are here

protected function RouteSubscriber::alterRoutes in WebP 8

Alters existing routes for a specific collection.

Parameters

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

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 18

Class

RouteSubscriber
Class RouteSubscriber.

Namespace

Drupal\webp\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  foreach ([
    'image.style_public',
    'image.style_private',
  ] as $route_id) {
    if ($route = $collection
      ->get($route_id)) {
      $route
        ->setDefault('_controller', 'Drupal\\webp\\Controller\\ImageStyleDownloadController::deliver');
    }
  }
  foreach ([
    'system.private_file_download',
    'system.files',
  ] as $route_id) {
    if ($route = $collection
      ->get($route_id)) {
      $route
        ->setDefault('_controller', 'Drupal\\webp\\Controller\\FileDownloadController::download');
    }
  }
}