PhotosRouteSubscriber.php in Album Photos 6.0.x
File
src/Routing/PhotosRouteSubscriber.php
View source
<?php
namespace Drupal\photos\Routing;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
class PhotosRouteSubscriber extends RouteSubscriberBase {
protected $configFactory;
public function __construct(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
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')) {
if ($route = $collection
->get('entity.photos_image.canonical')) {
$route
->setDefault('_controller', '\\Drupal\\photos\\Controller\\PhotosLegacyImageViewController::view');
}
}
}
}