Jobs setup
This commit is contained in:
@ -95,9 +95,9 @@ class Attachment implements Model
|
||||
public function getFullFilename(): string
|
||||
{
|
||||
return implode(' - ', [
|
||||
$this->getMessage()->getSubject(),
|
||||
$this->getMessage()->getDateTime()->format('Y-m-d His'),
|
||||
$this->getFilename()
|
||||
$this->getMessage()->getSubject(),
|
||||
$this->getFilename(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -25,24 +25,20 @@ class Job implements Model
|
||||
{
|
||||
return $this->arguments ?? '';
|
||||
}
|
||||
public function isExecuted(): bool
|
||||
{
|
||||
return $this->lastState()->getStatus() === State\Job::Executed;
|
||||
}
|
||||
|
||||
public function setId(int $id): Job
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
public function setCommand(string $message): Job
|
||||
public function setCommand(string $command): Job
|
||||
{
|
||||
$this->message = $message;
|
||||
$this->command = $command;
|
||||
return $this;
|
||||
}
|
||||
public function setArguments(string $dateTime): Job
|
||||
public function setArguments(string $arguments): Job
|
||||
{
|
||||
$this->dateTime = $dateTime;
|
||||
$this->arguments = $arguments;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -82,10 +78,14 @@ class Job implements Model
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isExecuted(): bool
|
||||
{
|
||||
return $this->lastState()->getStatus() === State\Job::Executed;
|
||||
}
|
||||
public function lastState(): State\Job
|
||||
{
|
||||
if (count($this->getStates()) === 0) {
|
||||
throw new Stateless($this);
|
||||
throw new Stateless($this->getId());
|
||||
}
|
||||
return $this->getStates()[array_key_last($this->getStates())];
|
||||
}
|
||||
@ -94,9 +94,9 @@ class Job implements Model
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'message' => $this->getMessage()->toArray(),
|
||||
'date_time' => $this->getDateTime()->format('Y-m-d H:i:s'),
|
||||
'executed' => $this->isExecuted()
|
||||
'command' => $this->getCommand(),
|
||||
'arguments' => $this->getArguments(),
|
||||
'states' => $this->getStates()
|
||||
];
|
||||
}
|
||||
public function jsonSerialize(): mixed
|
||||
|
@ -57,7 +57,7 @@ class Job implements Model
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'job' => $this->getJob(),
|
||||
'job_id' => $this->getJob()->getId(),
|
||||
'date' => $this->getDateTime(),
|
||||
'status' => $this->getStatus()
|
||||
];
|
||||
|
Reference in New Issue
Block a user