You are here

RouteSubscriber.php in Media Expire 8.2

Same filename and directory in other branches
  1. 8 src/Routing/RouteSubscriber.php

File

src/Routing/RouteSubscriber.php
View source
<?php

namespace Drupal\media_expire\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  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');
    }
  }

}

Classes

Namesort descending Description
RouteSubscriber Listens to the dynamic route events.