Feature: [cron] Create a cron manager

This commit is contained in:
2022-12-11 01:22:39 +01:00
parent 333e524136
commit 4fcfe3f5d2
6 changed files with 566 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Entity;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="chill_main_cronjob_execution")
*/
class CronJobExecution
{
public const FAILURE = 100;
public const SUCCESS = 1;
/**
* @ORM\Column(type="text", nullable=false)
* @ORM\Id
*/
private string $key;
/**
* @var DateTimeImmutable
* @ORM\Column(type="datetime_immutable, nullable=true, options={"default"": null})
*/
private ?DateTimeImmutable $lastEnd = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*/
private DateTimeImmutable $lastStart;
private ?int $lastStatus = null;
public function __construct(string $key)
{
$this->key = $key;
$this->lastStart = new DateTimeImmutable('now');
}
public function getKey(): string
{
return $this->key;
}
public function getLastEnd(): DateTimeImmutable
{
return $this->lastEnd;
}
public function getLastStart(): DateTimeImmutable
{
return $this->lastStart;
}
public function getLastStatus(): ?int
{
return $this->lastStatus;
}
public function setLastEnd(?DateTimeImmutable $lastEnd): CronJobExecution
{
$this->lastEnd = $lastEnd;
return $this;
}
public function setLastStart(DateTimeImmutable $lastStart): CronJobExecution
{
$this->lastStart = $lastStart;
return $this;
}
public function setLastStatus(?int $lastStatus): CronJobExecution
{
$this->lastStatus = $lastStatus;
return $this;
}
}