mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Feature: [cron] Create a cron manager
This commit is contained in:
92
src/Bundle/ChillMainBundle/Entity/CronJobExecution.php
Normal file
92
src/Bundle/ChillMainBundle/Entity/CronJobExecution.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user