You are here

class RouteSubscriber in Media Download 1.1.x

Same name and namespace in other branches
  1. 1.2.x src/RouteSubscriber.php \Drupal\media_download\RouteSubscriber
  2. 1.0.x src/RouteSubscriber.php \Drupal\media_download\RouteSubscriber

Replaces the core-provided canonical media entity route.

Copyright (C) 2021 Library Solutions, LLC (et al.).

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Hierarchy

Expanded class hierarchy of RouteSubscriber

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

File

src/RouteSubscriber.php, line 20

Namespace

Drupal\media_download
View source
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    $collection
      ->remove('entity.media.canonical');
    $collection
      ->add('entity.media.canonical', new Route('/media/{media}', [
      '_controller' => DownloadController::class . '::save',
    ], [
      '_entity_access' => 'media.view',
    ]));
  }

}

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 7
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1