You are here

public function RouteSubscriber::alterRoutes in Media Expire 8.2

Same name and namespace in other branches
  1. 8 src/Routing/RouteSubscriber.php \Drupal\media_expire\Routing\RouteSubscriber::alterRoutes()

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 16

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\media_expire\Routing

Code

public function alterRoutes(RouteCollection $collection) {
  $canonical = $collection
    ->get('entity.media.canonical');
  $edit = $collection
    ->get('entity.media.edit_form');
  if ($canonical && $edit && $canonical
    ->getPath() !== $edit
    ->getPath()) {
    $canonical
      ->setDefault('_controller', 'Drupal\\media_expire\\Controller\\MediaViewController::view');
  }
}