You are here

class RouteSubscriber in TinyPNG 8

Class RouteSubscriber.

@package Drupal\tinypng\Routing

Hierarchy

Expanded class hierarchy of RouteSubscriber

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

File

src/Routing/RouteSubscriber.php, line 13

Namespace

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

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

}

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