forked from cleverage/processuibundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessSchedule.php
More file actions
135 lines (110 loc) · 3.02 KB
/
ProcessSchedule.php
File metadata and controls
135 lines (110 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
declare(strict_types=1);
/*
* This file is part of the CleverAge/UiProcessBundle package.
*
* Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CleverAge\UiProcessBundle\Entity;
use CleverAge\UiProcessBundle\Entity\Enum\ProcessScheduleType;
use CleverAge\UiProcessBundle\Repository\ProcessScheduleRepository;
use CleverAge\UiProcessBundle\Validator\CronExpression;
use CleverAge\UiProcessBundle\Validator\EveryExpression;
use CleverAge\UiProcessBundle\Validator\IsValidProcessCode;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ProcessScheduleRepository::class)]
class ProcessSchedule
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[IsValidProcessCode]
private string $process;
#[ORM\Column(length: 6)]
private ProcessScheduleType $type;
#[ORM\Column(length: 255)]
#[Assert\When(
expression: 'this.getType().value == "cron"', constraints: [new CronExpression()]
)]
#[Assert\When(
expression: 'this.getType().value == "every"', constraints: [new EveryExpression()]
)]
private string $expression;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $input = null;
/**
* @var string|array<string|int, mixed>
*/
#[ORM\Column(type: Types::JSON)]
private string|array $context = [];
public function getId(): ?int
{
return $this->id;
}
public function getProcess(): ?string
{
return $this->process;
}
public function setProcess(string $process): static
{
$this->process = $process;
return $this;
}
/**
* @return array<string|int, mixed>
*/
public function getContext(): array
{
return \is_array($this->context) ? $this->context : json_decode($this->context);
}
/**
* @param array<string|int, mixed> $context
*/
public function setContext(array $context): void
{
$this->context = $context;
}
/**
* PHP 8.1 Fatal error: Null can not be used as a standalone type.
*
* @phpstan-ignore missingType.return
*/
public function getNextExecution()
{
return null;
}
public function getType(): ProcessScheduleType
{
return $this->type;
}
public function setType(ProcessScheduleType $type): self
{
$this->type = $type;
return $this;
}
public function getExpression(): ?string
{
return $this->expression;
}
public function setExpression(string $expression): self
{
$this->expression = $expression;
return $this;
}
public function getInput(): ?string
{
return $this->input;
}
public function setInput(?string $input): self
{
$this->input = $input;
return $this;
}
}