mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-24 23:28:40 +00:00
fixes #26
This commit is contained in:
parent
6cc520a579
commit
16e0462a89
|
|
@ -25,21 +25,6 @@ namespace phpOMS\Utils\TaskSchedule;
|
|||
*/
|
||||
class Cron extends SchedulerAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Normalize run result for easier parsing
|
||||
*
|
||||
* @param string $raw Raw command output
|
||||
*
|
||||
* @return string Normalized string for parsing
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function normalize(string $raw) : string
|
||||
{
|
||||
return \str_replace("\r\n", "\n", $raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS\Utils\TaskSchedule;
|
||||
|
||||
use phpOMS\Validation\Base\DateTime;
|
||||
|
||||
/**
|
||||
* CronJob class.
|
||||
*
|
||||
|
|
@ -29,10 +31,22 @@ class CronJob extends TaskAbstract
|
|||
*/
|
||||
public static function createWith(array $jobData) : TaskAbstract
|
||||
{
|
||||
$job = new self($jobData[5], '');
|
||||
$job = new self($jobData[1], '');
|
||||
|
||||
$job->setRun($jobData[5]);
|
||||
$job->setRun($jobData[8]);
|
||||
$job->setStatus($jobData[3]);
|
||||
|
||||
return $job;
|
||||
if (DateTime::isValid($jobData[2])) {
|
||||
$job->setNextRunTime(new \DateTime($jobData[2]));
|
||||
}
|
||||
|
||||
if (DateTime::isValid($jobData[5])) {
|
||||
$job->setLastRuntime(new \DateTime($jobData[5]));
|
||||
}
|
||||
|
||||
$job->setComment($jobData[10]);
|
||||
$job->addResult($jobData[6]);
|
||||
|
||||
return $job;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,22 +31,22 @@ class Schedule extends TaskAbstract
|
|||
*/
|
||||
public static function createWith(array $jobData) : TaskAbstract
|
||||
{
|
||||
$job = new self($jobData[1], '');
|
||||
$job = new self($jobData[1], '');
|
||||
|
||||
$job->setRun($jobData[8]);
|
||||
$job->setStatus($jobData[3]);
|
||||
$job->setRun($jobData[8]);
|
||||
$job->setStatus($jobData[3]);
|
||||
|
||||
if (DateTime::isValid($jobData[2])) {
|
||||
$job->setNextRunTime(new \DateTime($jobData[2]));
|
||||
}
|
||||
if (DateTime::isValid($jobData[2])) {
|
||||
$job->setNextRunTime(new \DateTime($jobData[2]));
|
||||
}
|
||||
|
||||
if (DateTime::isValid($jobData[5])) {
|
||||
$job->setLastRuntime(new \DateTime($jobData[5]));
|
||||
}
|
||||
if (DateTime::isValid($jobData[5])) {
|
||||
$job->setLastRuntime(new \DateTime($jobData[5]));
|
||||
}
|
||||
|
||||
$job->setComment($jobData[10]);
|
||||
$job->addResult($jobData[6]);
|
||||
$job->setComment($jobData[10]);
|
||||
$job->addResult($jobData[6]);
|
||||
|
||||
return $job;
|
||||
return $job;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,6 +182,20 @@ abstract class SchedulerAbstract
|
|||
$this->run($task->getCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize run result for easier parsing
|
||||
*
|
||||
* @param string $raw Raw command output
|
||||
*
|
||||
* @return string Normalized string for parsing
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function normalize(string $raw) : string
|
||||
{
|
||||
return \str_replace("\r\n", "\n", $raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all jobs/tasks by name
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,20 +25,6 @@ namespace phpOMS\Utils\TaskSchedule;
|
|||
*/
|
||||
class TaskScheduler extends SchedulerAbstract
|
||||
{
|
||||
/**
|
||||
* Normalize run result for easier parsing
|
||||
*
|
||||
* @param string $raw Raw command output
|
||||
*
|
||||
* @return string Normalized string for parsing
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function normalize(string $raw) : string
|
||||
{
|
||||
return \str_replace("\r\n", "\n", $raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user