class RouteSubscriber in Media Download 1.0.x
Same name and namespace in other branches
- 1.2.x src/RouteSubscriber.php \Drupal\media_download\RouteSubscriber
- 1.1.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
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\media_download\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
RouteSubscriber.php, line 20
Namespace
Drupal\media_downloadView 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
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriberBase:: |
public static | function | 7 | |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |