Skip to content
Snippets Groups Projects
Commit cc58eb9f authored by Shibin Das's avatar Shibin Das
Browse files

Issue #3495133 by d34dman: Defer to combined_image_style if its available.

parent ba84aca6
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,8 @@ services:
rift.route_subscriber:
class: Drupal\rift\Routing\RouteSubscriber
arguments:
- '@module_handler'
tags:
- { name: event_subscriber }
......
......@@ -2,18 +2,26 @@
namespace Drupal\rift\Routing;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Routing\RouteSubscriberBase;
use Drupal\Core\Routing\RoutingEvents;
use Symfony\Component\Routing\RouteCollection;
class RouteSubscriber extends RouteSubscriberBase {
public function __construct(
private ModuleHandlerInterface $moduleHandler
) {}
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection): void {
/** @var \Symfony\Component\Routing\Route $route */
if ($route = $collection->get('image.style_public')) {
if ($this->moduleHandler->moduleExists('combined_image_style')) {
return;
}
$path = $route->getPath();
$route->setPath(str_replace('image_style', 'image_styles', $path));
......@@ -26,9 +34,7 @@ class RouteSubscriber extends RouteSubscriberBase {
*/
public static function getSubscribedEvents(): array {
$events = [];
if (!\Drupal::moduleHandler()->moduleExists('combined_image_styles')) {
$events[RoutingEvents::ALTER] = ['onAlterRoutes', -1025];
}
$events[RoutingEvents::ALTER] = ['onAlterRoutes', -1024];
return $events;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment