Skip to content

Commit

Permalink
Merge pull request #89 from creative-commoners/pulls/3.0/remove-self
Browse files Browse the repository at this point in the history
ENH Use class name instead of self
  • Loading branch information
GuySartorelli authored Jun 17, 2024
2 parents 65b5b11 + cadce9e commit fbcbc79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/Controllers/CronTaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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')]
),
Expand Down
2 changes: 1 addition & 1 deletion tests/CronTaskTest/TestCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public function getSchedule()

public function process()
{
++self::$times_run;
++TestCron::$times_run;
}
}

0 comments on commit fbcbc79

Please sign in to comment.