From cadce9eac9b65268d122abb7758f286fbe3dd669 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 5 Jun 2024 17:24:10 +1200 Subject: [PATCH] ENH Use class name instead of self --- src/Controllers/CronTaskController.php | 16 +++++++++++++--- tests/CronTaskTest/TestCron.php | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Controllers/CronTaskController.php b/src/Controllers/CronTaskController.php index d80bedb..6127482 100644 --- a/src/Controllers/CronTaskController.php +++ b/src/Controllers/CronTaskController.php @@ -110,7 +110,13 @@ public function index(HTTPRequest $request) // Check each task $tasks = ClassInfo::implementorsOf(CronTask::class); if (empty($tasks)) { - $this->output(_t(self::class . '.NO_IMPLEMENTERS', 'There are no implementators of CronTask to run'), 2); + $this->output( + _t( + CronTaskController::class . '.NO_IMPLEMENTERS', + 'There are no implementators of CronTask to run' + ), + 2 + ); return; } foreach ($tasks as $subclass) { @@ -134,12 +140,16 @@ public function runTask(CronTask $task) // Update status of this task prior to execution in case of interruption CronTaskStatus::update_status(get_class($task), $isDue); if ($isDue) { - $this->output(_t(self::class . '.WILL_START_NOW', '{task} will start now.', ['task' => get_class($task)])); + $this->output(_t( + CronTaskController::class . '.WILL_START_NOW', + '{task} will start now.', + ['task' => get_class($task)] + )); $task->process(); } else { $this->output( _t( - self::class . '.WILL_RUN_AT', + CronTaskController::class . '.WILL_RUN_AT', '{task} will run at {time}.', ['task' => get_class($task), 'time' => $cron->getNextRunDate()->format('Y-m-d H:i:s')] ), diff --git a/tests/CronTaskTest/TestCron.php b/tests/CronTaskTest/TestCron.php index c0b29eb..b99c21e 100644 --- a/tests/CronTaskTest/TestCron.php +++ b/tests/CronTaskTest/TestCron.php @@ -20,6 +20,6 @@ public function getSchedule() public function process() { - ++self::$times_run; + ++TestCron::$times_run; } }