You are here

class PhotosRouteSubscriber in Album Photos 8.5

Same name and namespace in other branches
  1. 6.0.x src/Routing/PhotosRouteSubscriber.php \Drupal\photos\Routing\PhotosRouteSubscriber

Listens to the dynamic route events.

Hierarchy

Expanded class hierarchy of PhotosRouteSubscriber

1 string reference to 'PhotosRouteSubscriber'
photos.services.yml in ./photos.services.yml
photos.services.yml
1 service uses PhotosRouteSubscriber
photos.route_subscriber in ./photos.services.yml
Drupal\photos\Routing\PhotosRouteSubscriber

File

src/Routing/PhotosRouteSubscriber.php, line 12

Namespace

Drupal\photos\Routing
View source
class PhotosRouteSubscriber extends RouteSubscriberBase {

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a new PhotosRouteSubscriber.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($this->configFactory
      ->get('photos.settings')
      ->get('photos_legacy_view_mode')) {

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

}

Members

Namesort descending Modifiers Type Description Overrides
PhotosRouteSubscriber::$configFactory protected property The config factory.
PhotosRouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
PhotosRouteSubscriber::__construct public function Constructs a new PhotosRouteSubscriber.
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1