From 3d684a8800ee8be21094ddd5e0c233370f63793b Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 25 Jul 2023 20:25:55 -0700 Subject: [PATCH] Fix remaining deprecations --- src/Command/CleanupCommand.php | 3 +-- src/Controller/AppController.php | 3 +++ src/Controller/ProjectsController.php | 9 ++++++--- src/Model/Table/SimpleSortable.php | 4 +--- src/Model/Table/TasksTable.php | 5 ++--- .../Command/CalendarSubscriptionRenewCommandTest.php | 2 +- tests/TestCase/Command/CleanupCommandTest.php | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Command/CleanupCommand.php b/src/Command/CleanupCommand.php index 3957df57..06da3d5e 100644 --- a/src/Command/CleanupCommand.php +++ b/src/Command/CleanupCommand.php @@ -51,8 +51,7 @@ public function execute(Arguments $args, ConsoleIo $io) $io->verbose("Going to remove tasks older than {$expires->toDateTimeString()}"); $tasks = $this->fetchTable('Tasks'); - $query = $tasks->query() - ->delete() + $query = $tasks->deleteQuery() ->where([ 'Tasks.deleted_at IS NOT' => null, 'Tasks.deleted_at <' => $expires, diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 55241939..1799e773 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -3,6 +3,7 @@ namespace App\Controller; +use App\Model\Table\ProjectsTable; use Authentication\Authenticator\SessionAuthenticator; use Cake\Controller\Controller; use Cake\Event\EventInterface; @@ -26,6 +27,8 @@ class AppController extends Controller beforeRender as protected inertiaBeforeRender; } + public ProjectsTable $Projects; + /** * Initialization hook method. * diff --git a/src/Controller/ProjectsController.php b/src/Controller/ProjectsController.php index f0a87b12..0ce19efc 100644 --- a/src/Controller/ProjectsController.php +++ b/src/Controller/ProjectsController.php @@ -4,21 +4,24 @@ namespace App\Controller; use App\Model\Entity\Project; +use App\Model\Table\ProjectsTable; +use App\Model\Table\TasksTable; use Cake\View\JsonView; use InvalidArgumentException; /** * Projects Controller - * - * @property \App\Model\Table\TasksTable $Tasks - * @property \App\Model\Table\ProjectsTable $Projects */ class ProjectsController extends AppController { + public TasksTable $Tasks; + public ProjectsTable $Projects; + public function initialize(): void { parent::initialize(); $this->loadModel('Tasks'); + $this->loadModel('Projects'); } public function viewClasses(): array diff --git a/src/Model/Table/SimpleSortable.php b/src/Model/Table/SimpleSortable.php index a5a7a96b..24bf91f4 100644 --- a/src/Model/Table/SimpleSortable.php +++ b/src/Model/Table/SimpleSortable.php @@ -53,9 +53,7 @@ public function move(EntityInterface $record, $newIndex, array $scopeConditions) $targetOffset = $currentTask->get($field); } - $query = $this->table->query() - ->update() - ->where($scopeConditions); + $query = $this->table->updateQuery()->where($scopeConditions); $current = $record->get($field); $record->set($field, $targetOffset); diff --git a/src/Model/Table/TasksTable.php b/src/Model/Table/TasksTable.php index aa74c396..d720dea5 100644 --- a/src/Model/Table/TasksTable.php +++ b/src/Model/Table/TasksTable.php @@ -158,7 +158,7 @@ public function find(string $type = 'all', array $options = []): Query { // Add the default deleted condition unless the `deleted` option is set. $operator = empty($options['deleted']) ? 'IS' : 'IS NOT'; - $query = $this->query()->select(); + $query = $this->selectQuery(); $query->where(["Tasks.deleted_at {$operator}" => null]); return $this->callFinder($type, $query, $options); @@ -353,8 +353,7 @@ public function move(Task $item, array $operation) $targetOffset = $result->max + 1; } - $query = $this->query() - ->update() + $query = $this->updateQuery() ->innerJoinWith('Projects') ->where($conditions); diff --git a/tests/TestCase/Command/CalendarSubscriptionRenewCommandTest.php b/tests/TestCase/Command/CalendarSubscriptionRenewCommandTest.php index 7735e4f0..7b276afe 100644 --- a/tests/TestCase/Command/CalendarSubscriptionRenewCommandTest.php +++ b/tests/TestCase/Command/CalendarSubscriptionRenewCommandTest.php @@ -4,8 +4,8 @@ namespace App\Test\TestCase\Command; use App\Test\TestCase\FactoryTrait; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\ORM\TableRegistry; -use Cake\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; /** diff --git a/tests/TestCase/Command/CleanupCommandTest.php b/tests/TestCase/Command/CleanupCommandTest.php index 967a801f..3b2f5b6d 100644 --- a/tests/TestCase/Command/CleanupCommandTest.php +++ b/tests/TestCase/Command/CleanupCommandTest.php @@ -4,8 +4,8 @@ namespace App\Test\TestCase\Command; use App\Test\TestCase\FactoryTrait; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; use Cake\I18n\FrozenTime; -use Cake\TestSuite\ConsoleIntegrationTestTrait; use Cake\TestSuite\TestCase; /**