Merge ApiPendingChangesController and ApiPublishAllController, clarify connection

Created on 11 February 2025, 24 days ago

Overview

Identified in โœจ Auto-save code components Active .

See https://git.drupalcode.org/project/experience_builder/-/merge_requests/5...

It's very confusing that:

  1. the "collection" of autosaves doesn't actually return the autosaved data, but only hashes, plus additional metadata (because it's powering the "Review changes" UI functionality)
  2. the "publish all" is connected to autosaves, and requires the hashes of point 1 to be sent โ€” otherwise it'll fail validation: \Drupal\experience_builder\Controller\ApiPublishAllController::validateExpectedAutoSaves()

Proposed resolution

Merge the two controllers, and also make it clear in the route definitions that the two are strongly connected. So, something like:

 experience_builder.routing.yml | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/experience_builder.routing.yml b/experience_builder.routing.yml
index 8563b461..04ff8d8e 100644
--- a/experience_builder.routing.yml
+++ b/experience_builder.routing.yml
@@ -43,12 +43,20 @@ experience_builder.api.preview:
       entity:
         type: entity:{entity_type}
 
-experience_builder.api.autosave_collection:
-  path: '/xb/api/autosave'
+experience_builder.api.autosave.get:
+  path: '/xb/api/autosaves/pending'
   defaults:
-    _controller: 'Drupal\experience_builder\Controller\ApiPendingChangesController'
+      _controller: 'Drupal\experience_builder\Controller\ApiAutoSaveController::get'
   requirements:
     _permission: 'access administration pages'
+  methods: [GET]
+experience_builder.api.autosave.post:
+  path: '/xb/api/autosaves/publish'
+  defaults:
+    _controller: 'Drupal\experience_builder\Controller\ApiAutoSaveController::post'
+  requirements:
+    _permission: 'access administration pages'
+  methods: [POST]
 
 entity.component.delete_form:
   path: '/admin/structure/component/delete/{component}'
@@ -200,10 +208,3 @@ entity.component.disable:
     _entity_access: 'component.disable'
     _csrf_token: 'TRUE'
 
-experience_builder.api.publish_all:
-  path: '/xb/api/publish-all'
-  defaults:
-    _controller: 'Drupal\experience_builder\Controller\ApiPublishAllController'
-  requirements:
-    _permission: 'access administration pages'
-  methods: [POST]

User interface changes

๐Ÿ“Œ Task
Status

Active

Version

0.0

Component

Internal HTTP API

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024