You are here

protected function RouteSubscriber::alterRoutes in TinyPNG 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\tinypng\Routing

Code

protected function alterRoutes(RouteCollection $collection) {

  // This is not a good solution. Replace this if
  // https://www.drupal.org/project/drupal/issues/2940016 is closed.

  /** @var \Symfony\Component\Routing\Route $route */
  if ($route = $collection
    ->get('image.style_public')) {
    $route
      ->setDefault('_controller', '\\Drupal\\tinypng\\Controller\\TinyPngImageStyleDownloadController::deliver');
  }
  if ($route = $collection
    ->get('image.style_private')) {
    $route
      ->setDefault('_controller', '\\Drupal\\tinypng\\Controller\\TinyPngImageStyleDownloadController::deliver');
  }
}