Skip to content

Commit

Permalink
Fix up deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Nov 11, 2021
1 parent 92101a3 commit fc7c83f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
28 changes: 28 additions & 0 deletions src/Controller/Admin/LoadHelperTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Queue\Controller\Admin;

use Cake\Core\Configure;

trait LoadHelperTrait {

/**
* @return void
*/
protected function loadHelpers(): void {
$helpers = [
'Time' => ['class' => 'Tools.Time', 'engine' => 'Tools\Utility\FrozenTime'],
'Tools.Format',
'Tools.Text',
'Shim.Configure',
];

$version = Configure::version();
if (version_compare($version, '4.3.0') >= 0) {
$this->viewBuilder()->addHelpers($helpers);
} else {
$this->viewBuilder()->setHelpers($helpers);
}
}

}
4 changes: 3 additions & 1 deletion src/Controller/Admin/QueueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
class QueueController extends AppController {

use LoadHelperTrait;

/**
* @var string
*/
Expand All @@ -24,7 +26,7 @@ class QueueController extends AppController {
public function initialize(): void {
parent::initialize();

$this->viewBuilder()->setHelpers(['Tools.Time' => ['engine' => 'Tools\Utility\FrozenTime'], 'Tools.Format', 'Tools.Text', 'Shim.Configure'], false);
$this->loadHelpers();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Controller/Admin/QueueProcessesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
class QueueProcessesController extends AppController {

use LoadHelperTrait;

/**
* @var array
*/
Expand All @@ -29,7 +31,7 @@ class QueueProcessesController extends AppController {
public function initialize(): void {
parent::initialize();

$this->viewBuilder()->setHelpers(['Tools.Time' => ['engine' => 'Tools\Utility\FrozenTime'], 'Tools.Format', 'Tools.Text', 'Shim.Configure'], false);
$this->loadHelpers();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Controller/Admin/QueuedJobsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
class QueuedJobsController extends AppController {

use LoadHelperTrait;

/**
* @var array
*/
Expand All @@ -41,7 +43,7 @@ public function initialize(): void {
}

$this->enableSearch();
$this->viewBuilder()->setHelpers(['Tools.Time' => ['engine' => 'Tools\Utility\FrozenTime'], 'Tools.Format', 'Tools.Text', 'Shim.Configure'], false);
$this->loadHelpers();
}

/**
Expand Down

0 comments on commit fc7c83f

Please sign in to comment.