tweaked library to work with codeigniter

This commit is contained in:
HB9HIL
2024-04-25 08:36:06 +02:00
parent 53f124a10e
commit b3d6fabe2c
2 changed files with 12 additions and 7 deletions

View File

@@ -51,8 +51,12 @@ class cron extends CI_Controller {
if ($cron->enabled == 1) {
// calculate the crons expression
$this->load->library('CronExpression');
$cronjob = CronExpression::parse($cron->expression); // Verwende die statische Methode der CronExpression-Klasse
$data = array(
'expression' => $cron->expression,
'timeZone' => null
);
$this->load->library('CronExpression', $data);
$cronjob = $this->cronexpression;
$dt = new DateTime();
$isdue = $cronjob->isMatching($dt);
@@ -101,6 +105,7 @@ class cron extends CI_Controller {
// Set the next_run timestamp to null to indicate in the view/database that this cron is disabled
$this->cron_model->set_next_run($cron->id, null);
}
$this->cronexpression = null;
}
}
}

View File

@@ -86,14 +86,14 @@ class CronExpression {
/**
* @param string $expression a cron expression, e.g. "* * * * *"
* @param DateTimeZone|null $timeZone time zone object
* @param DateTimeZone|null $timeZone time zone objectstring $expression, DateTimeZone $timeZone = null
*/
public function __construct(string $expression, DateTimeZone $timeZone = null) {
$this->timeZone = $timeZone;
$this->expression = $expression;
public function __construct($data) {
$this->timeZone = $data['timeZone'];
$this->expression = $data['expression'];
try {
$this->registers = $this->parse($expression);
$this->registers = $this->parse($data['expression']);
} catch (Exception $e) {
$this->registers = null;
}