You are here

class RouteSubscriber in Display Suite 8.4

Same name in this branch
  1. 8.4 src/Routing/RouteSubscriber.php \Drupal\ds\Routing\RouteSubscriber
  2. 8.4 modules/ds_devel/src/Routing/RouteSubscriber.php \Drupal\ds_devel\Routing\RouteSubscriber
  3. 8.4 modules/ds_extras/src/EventSubscriber/RouteSubscriber.php \Drupal\ds_extras\EventSubscriber\RouteSubscriber
Same name and namespace in other branches
  1. 8.2 modules/ds_extras/src/EventSubscriber/RouteSubscriber.php \Drupal\ds_extras\EventSubscriber\RouteSubscriber
  2. 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
ds_extras.route_subscriber in modules/ds_extras/ds_extras.services.yml
Drupal\ds_extras\EventSubscriber\RouteSubscriber

File

modules/ds_extras/src/EventSubscriber/RouteSubscriber.php, line 12

Namespace

Drupal\ds_extras\EventSubscriber
View 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

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::alterRoutes public function Alters the routes.
RouteSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.