You are here

class RouteSubscriber in WebP 8

Class RouteSubscriber.

Listens to the dynamic route events.

Hierarchy

Expanded class hierarchy of RouteSubscriber

1 string reference to 'RouteSubscriber'
webp.services.yml in ./webp.services.yml
webp.services.yml
1 service uses RouteSubscriber
webp.route_subscriber in ./webp.services.yml
Drupal\webp\Routing\RouteSubscriber

File

src/Routing/RouteSubscriber.php, line 13

Namespace

Drupal\webp\Routing
View source
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  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');
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1