class RouteSubscriber in Display Suite 8.4
Same name in this branch
- 8.4 src/Routing/RouteSubscriber.php \Drupal\ds\Routing\RouteSubscriber
- 8.4 modules/ds_devel/src/Routing/RouteSubscriber.php \Drupal\ds_devel\Routing\RouteSubscriber
- 8.4 modules/ds_extras/src/EventSubscriber/RouteSubscriber.php \Drupal\ds_extras\EventSubscriber\RouteSubscriber
Same name and namespace in other branches
- 8.2 modules/ds_extras/src/EventSubscriber/RouteSubscriber.php \Drupal\ds_extras\EventSubscriber\RouteSubscriber
- 8.3 modules/ds_extras/src/EventSubscriber/RouteSubscriber.php \Drupal\ds_extras\EventSubscriber\RouteSubscriber
Alter the node view route.
Hierarchy
- class \Drupal\ds_extras\EventSubscriber\RouteSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
- ds_extras.services.yml in modules/
ds_extras/ ds_extras.services.yml - modules/ds_extras/ds_extras.services.yml
1 service uses RouteSubscriber
File
- modules/
ds_extras/ src/ EventSubscriber/ RouteSubscriber.php, line 12
Namespace
Drupal\ds_extras\EventSubscriberView source
class RouteSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[RoutingEvents::ALTER][] = [
'alterRoutes',
100,
];
return $events;
}
/**
* Alters the routes.
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The event to process.
*/
public function alterRoutes(RouteBuildEvent $event) {
if (\Drupal::config('ds_extras.settings')
->get('override_node_revision')) {
$route = $event
->getRouteCollection()
->get('entity.node.revision');
if (!empty($route)) {
$route
->setDefault('_controller', '\\Drupal\\ds_extras\\Controller\\DsExtrasController::revisionShow');
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
public | function | Alters the routes. | |
RouteSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. |