From e2ee398c45d418ff987ec5a8dce654f5149fc41d Mon Sep 17 00:00:00 2001
From: Andrei Mateescu <andrei@amateescu.me>
Date: Thu, 20 Mar 2025 12:26:34 +0200
Subject: [PATCH] Ensure that route altering runs after workspaces_ui.

---
 .../src/Routing/RouteSubscriber.php                 | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/entity_workflow_workspace/src/Routing/RouteSubscriber.php b/modules/entity_workflow_workspace/src/Routing/RouteSubscriber.php
index a61d5da..b0d4942 100644
--- a/modules/entity_workflow_workspace/src/Routing/RouteSubscriber.php
+++ b/modules/entity_workflow_workspace/src/Routing/RouteSubscriber.php
@@ -3,6 +3,7 @@
 namespace Drupal\entity_workflow_workspace\Routing;
 
 use Drupal\Core\Routing\RouteSubscriberBase;
+use Drupal\Core\Routing\RoutingEvents;
 use Symfony\Component\Routing\RouteCollection;
 
 /**
@@ -16,7 +17,7 @@ class RouteSubscriber extends RouteSubscriberBase {
   /**
    * {@inheritdoc}
    */
-  protected function alterRoutes(RouteCollection $collection) {
+  protected function alterRoutes(RouteCollection $collection): void {
     // Disallow access the generic 'Publish' and 'Revert' routes, these actions
     // are done with workflow transitions.
     if ($route = $collection->get('entity.workspace.publish_form')) {
@@ -27,4 +28,14 @@ class RouteSubscriber extends RouteSubscriberBase {
     }
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function getSubscribedEvents(): array {
+    $events = parent::getSubscribedEvents();
+    // Run after \Drupal\workspaces_ui\Routing\RouteSubscriber.
+    $events[RoutingEvents::ALTER] = ['onAlterRoutes', -100];
+    return $events;
+  }
+
 }
-- 
GitLab