From 9830997f1cde5e75c5af6fc8858340acdcd79d68 Mon Sep 17 00:00:00 2001 From: Benn Oshrin Date: Tue, 28 Oct 2025 16:16:44 -0400 Subject: [PATCH] Additional commit for CFM-24 --- app/src/Controller/StandardController.php | 31 +++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index c90cb86e9..c7e6475cd 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -493,6 +493,19 @@ public function edit(string $id) { $this->set('vv_subtitle', $subtitle); } + // Inject the changelog archive information so the view can render it, similar to view + $clAttr = $obj->changelogAttributeName(); + + // As a first pass, we only pull the object itself (no related models) + + $archives = $table->find() + ->applyOptions(['archived' => true]) + ->where([$clAttr => $id]) + ->order(['revision' => 'DESC']) + ->all(); + + $this->set('vv_archives', $archives); + // Let the view render $this->render('/Standard/add-edit-view'); } @@ -781,8 +794,10 @@ public function view($id = null) { $table = $this->getCurrentTable(); // We use findById() rather than get() so we can apply subsequent - // query modifications via traits - $query = $table->findById($id); + // query modifications via traits. We allow ChangelogBehavior to return + // archived copies when directly queried. + $query = $table->findById($id) + ->applyOptions(['archived' => true]); // QueryModificationTrait if(method_exists($table, "getViewContains")) { @@ -816,6 +831,18 @@ public function view($id = null) { $this->set('vv_supertitle', $supertitle); $this->set('vv_subtitle', $subtitle); + // Inject the changelog archive information so the view can render it, similar to edit + $clAttr = $obj->changelogAttributeName(); + + // As a first pass, we only pull the object itself (no related models) + $archives = $table->find() + ->applyOptions(['archived' => true]) + ->where([$clAttr => $id]) + ->order(['revision' => 'DESC']) + ->all(); + + $this->set('vv_archives', $archives); + // Let the view render $this->render('/Standard/add-edit-view'); }