You are here

protected function PhotosRouteSubscriber::alterRoutes in Album Photos 6.0.x

Same name and namespace in other branches
  1. 8.5 src/Routing/PhotosRouteSubscriber.php \Drupal\photos\Routing\PhotosRouteSubscriber::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/PhotosRouteSubscriber.php, line 34

Class

PhotosRouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\photos\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  $config = $this->configFactory
    ->get('photos.settings');
  if ($config
    ->get('upload_form_mode') == 1) {
    if ($route = $collection
      ->get('photos.node.management')) {
      $route
        ->setDefaults([
        '_entity_form' => 'photos_image.add',
      ]);
    }
  }
  if ($config
    ->get('photos_legacy_view_mode')) {

    // An attempt to preserve image layouts configured pre 6.0.x.
    if ($route = $collection
      ->get('entity.photos_image.canonical')) {
      $route
        ->setDefault('_controller', '\\Drupal\\photos\\Controller\\PhotosLegacyImageViewController::view');
    }
  }
}