diff --git a/composer.json b/composer.json index c45732f..9176000 100644 --- a/composer.json +++ b/composer.json @@ -8,9 +8,10 @@ "cakephp/cakephp": "^5.0.1", "dragonmantank/cron-expression": "^3.3", "dereuromark/cakephp-tools": "^3.0.0", - "dereuromark/cakephp-queue": "^7.0.0" + "dereuromark/cakephp-queue": "^7.0.0 || ^8.0.0" }, "require-dev": { + "dereuromark/cakephp-templating": "^0.2.2", "cakephp/migrations": "^4.1.0", "phpunit/phpunit": "^10.3", "fig-r/psr2r-sniffer": "dev-next" diff --git a/src/Controller/Admin/LoadHelperTrait.php b/src/Controller/Admin/LoadHelperTrait.php new file mode 100644 index 0000000..8d1fd57 --- /dev/null +++ b/src/Controller/Admin/LoadHelperTrait.php @@ -0,0 +1,34 @@ +viewBuilder()->addHelpers($helpers); + } + +} diff --git a/src/Controller/Admin/QueueSchedulerController.php b/src/Controller/Admin/QueueSchedulerController.php index 232a038..794af7d 100644 --- a/src/Controller/Admin/QueueSchedulerController.php +++ b/src/Controller/Admin/QueueSchedulerController.php @@ -3,22 +3,20 @@ namespace QueueScheduler\Controller\Admin; use Cake\Utility\Hash; +use Queue\Controller\Admin\LoadHelperTrait; use QueueScheduler\Controller\AppController; -use Templating\View\Helper\IconHelper; class QueueSchedulerController extends AppController { + use LoadHelperTrait; + /** * @return void */ public function initialize(): void { parent::initialize(); - $this->viewBuilder()->addHelpers([ - class_exists(IconHelper::class) ? 'Templating.Icon' : 'Tools.Icon', - 'Queue.Queue', - 'Queue.QueueProgress', - ]); + $this->loadHelpers(); } /** diff --git a/src/Controller/Admin/SchedulerRowsController.php b/src/Controller/Admin/SchedulerRowsController.php index d479fb6..7e2d8c2 100644 --- a/src/Controller/Admin/SchedulerRowsController.php +++ b/src/Controller/Admin/SchedulerRowsController.php @@ -2,8 +2,8 @@ namespace QueueScheduler\Controller\Admin; +use Queue\Controller\Admin\LoadHelperTrait; use QueueScheduler\Controller\AppController; -use Templating\View\Helper\IconHelper; /** * Rows Controller @@ -13,16 +13,15 @@ */ class SchedulerRowsController extends AppController { + use LoadHelperTrait; + /** * @return void */ public function initialize(): void { parent::initialize(); - $this->viewBuilder()->addHelpers([ - 'Tools.Format', - class_exists(IconHelper::class) ? 'Templating.Icon' : 'Tools.Icon', - ]); + $this->loadHelpers(); } /** diff --git a/templates/Admin/SchedulerRows/index.php b/templates/Admin/SchedulerRows/index.php index 9a76560..ea04e7d 100644 --- a/templates/Admin/SchedulerRows/index.php +++ b/templates/Admin/SchedulerRows/index.php @@ -39,9 +39,9 @@ name) ?> type) ?> frequency) ?> - Format->yesNo($row->allow_concurrent) ?> + element('QueueScheduler.yes_no', ['value' => $row->allow_concurrent]) ?> - Format->yesNo($row->enabled) ?> + element('QueueScheduler.yes_no', ['value' => $row->enabled]) ?> enabled && $row->type === $row::TYPE_SHELL_COMMAND && !\Cake\Core\Configure::read('QueueScheduler.allowRaw')) { ?> Icon->render('stop-circle', [], ['title' => 'Raw commands are currently configured to be not runnable on non-debug system for security reasons.']); ?> diff --git a/templates/Admin/SchedulerRows/view.php b/templates/Admin/SchedulerRows/view.php index e6837e3..13cd015 100644 --- a/templates/Admin/SchedulerRows/view.php +++ b/templates/Admin/SchedulerRows/view.php @@ -40,7 +40,7 @@ - Format->yesNo($row->allow_concurrent) ?> allow_concurrent ? __('Yes') : __('No'); ?> + element('QueueScheduler.yes_no', ['value' => $row->allow_concurrent]) ?> allow_concurrent ? __('Yes') : __('No'); ?>
diff --git a/templates/element/yes_no.php b/templates/element/yes_no.php new file mode 100644 index 0000000..358886e --- /dev/null +++ b/templates/element/yes_no.php @@ -0,0 +1,17 @@ + +helpers()->has('IconSnippet')) { + echo $this->IconSnippet->yesNo($value); + } elseif ($this->helpers()->has('Format')) { + echo $this->Format->yesNo($value); + } else { + echo $value ? 'Yes' : 'No'; + } +?> diff --git a/tests/TestCase/Utility/CommandFinderTest.php b/tests/TestCase/Utility/CommandFinderTest.php index 6b688c8..a30db25 100644 --- a/tests/TestCase/Utility/CommandFinderTest.php +++ b/tests/TestCase/Utility/CommandFinderTest.php @@ -16,13 +16,13 @@ public function testAll() { Plugin::getCollection()->add(new QueuePlugin()); $result = (new CommandFinder())->all(); + unset($result['Queue.MigrateTasks']); $expected = [ 'Queue.BakeQueueTask' => 'Queue.BakeQueueTask', 'Queue.Worker' => 'Queue.Worker', 'Queue.Job' => 'Queue.Job', 'Queue.Run' => 'Queue.Run', 'Queue.Add' => 'Queue.Add', - 'Queue.MigrateTasks' => 'Queue.MigrateTasks', 'Queue.Info' => 'Queue.Info', 'QueueScheduler.Run' => 'QueueScheduler.Run', 'Tools.Inflect' => 'Tools.Inflect', diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 12c2b29..e620126 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,8 +8,8 @@ use Cake\Database\Connection; use Cake\Datasource\ConnectionManager; use Cake\TestSuite\Fixture\SchemaLoader; +use Templating\View\Icon\BootstrapIcon; use TestApp\Controller\AppController; -use Tools\View\Icon\BootstrapIcon; if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); @@ -96,7 +96,7 @@ class_alias(AppController::class, 'App\Controller\AppController'); ]); Configure::write('Icon', [ - 'sets' => ['bs' => \Tools\View\Icon\BootstrapIcon::class], + 'sets' => ['bs' => BootstrapIcon::class], ]); Plugin::getCollection()->add(new QueueScheduler\QueueSchedulerPlugin());