Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/Controller/Admin/QueueAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,34 @@

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;

/**
* @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();

Expand Down
12 changes: 12 additions & 0 deletions tests/TestCase/Controller/Admin/QueueControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down
Loading