From b57b90bb625540472962b259be584b2c3f1d7450 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 18 Mar 2026 06:24:27 +0100 Subject: [PATCH] Restore AppController extension with standalone opt-in By default, QueueAppController extends App\Controller\AppController to inherit app authentication, components, and configuration (BC). Set `Queue.standalone` to `true` for an isolated admin that doesn't depend on the host app's AppController setup. --- src/Controller/Admin/QueueAppController.php | 20 +++++++++++++------ .../Controller/Admin/QueueControllerTest.php | 12 +++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Controller/Admin/QueueAppController.php b/src/Controller/Admin/QueueAppController.php index 0c253e98..23416c58 100644 --- a/src/Controller/Admin/QueueAppController.php +++ b/src/Controller/Admin/QueueAppController.php @@ -3,16 +3,19 @@ namespace Queue\Controller\Admin; +use App\Controller\AppController; use Cake\Controller\Controller; use Cake\Core\Configure; /** * QueueAppController * - * Isolated base controller for Queue admin that doesn't depend on host app's AppController. - * This ensures the admin dashboard can function independently with its own layout and styling. + * Base controller for Queue admin. + * + * By default, extends AppController to inherit app authentication, components, and configuration. + * Set `Queue.standalone` to `true` for an isolated admin that doesn't depend on the host app. */ -class QueueAppController extends Controller { +class QueueAppController extends AppController { use LoadHelperTrait; @@ -20,9 +23,14 @@ class QueueAppController extends Controller { * @return void */ public function initialize(): void { - parent::initialize(); - - $this->loadComponent('Flash'); + if (Configure::read('Queue.standalone')) { + // Standalone mode: skip app's AppController, initialize independently + Controller::initialize(); + $this->loadComponent('Flash'); + } else { + // Default: inherit app's full controller setup + parent::initialize(); + } $this->loadHelpers(); diff --git a/tests/TestCase/Controller/Admin/QueueControllerTest.php b/tests/TestCase/Controller/Admin/QueueControllerTest.php index 94a40539..ae2dbc40 100644 --- a/tests/TestCase/Controller/Admin/QueueControllerTest.php +++ b/tests/TestCase/Controller/Admin/QueueControllerTest.php @@ -3,6 +3,7 @@ namespace Queue\Test\TestCase\Controller\Admin; +use Cake\Core\Configure; use Cake\Datasource\ConnectionManager; use Cake\Http\ServerRequest; use Cake\I18n\DateTime; @@ -276,6 +277,17 @@ public function testHardReset() { $this->assertSame(0, $count); } + /** + * @return void + */ + public function testIndexStandalone(): void { + Configure::write('Queue.standalone', true); + + $this->get(['prefix' => 'Admin', 'plugin' => 'Queue', 'controller' => 'Queue', 'action' => 'index']); + + $this->assertResponseCode(200); + } + /** * Helper method for skipping tests that need a real connection. *