1 | <?php |
||
27 | class Task |
||
28 | { |
||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | const STATUS_ENABLED = 1; |
||
33 | |||
34 | /** |
||
35 | * @var int |
||
36 | */ |
||
37 | const STATUS_DISABLED = 0; |
||
38 | |||
39 | /** |
||
40 | * @ORM\Id |
||
41 | * @ORM\GeneratedValue |
||
42 | * @ORM\Column(type="integer") |
||
43 | * |
||
44 | * @var int |
||
45 | */ |
||
46 | protected $id; |
||
47 | |||
48 | /** |
||
49 | * @ORM\Column(type="string", length=128) |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $command = ''; |
||
54 | |||
55 | /** |
||
56 | * @ORM\Column(type="datetime", nullable=true) |
||
57 | * @Assert\DateTime() |
||
58 | * |
||
59 | * @var \DateTime|null |
||
60 | */ |
||
61 | protected $last_run; |
||
62 | |||
63 | /** |
||
64 | * @ORM\Column(type="datetime") |
||
65 | * @Assert\DateTime() |
||
66 | * |
||
67 | * @var \DateTime |
||
68 | */ |
||
69 | protected $next_run; |
||
70 | |||
71 | /** |
||
72 | * A date/time string |
||
73 | * |
||
74 | * Valid formats are explained in Date and Time Formats. |
||
75 | * |
||
76 | * @link http://www.php.net/manual/en/datetime.formats.php |
||
77 | * @ORM\Column(type="string", length=128, nullable=true) |
||
78 | * |
||
79 | * @var string |
||
80 | */ |
||
81 | protected $modify = ''; |
||
82 | |||
83 | /** |
||
84 | * @ORM\Column(type="integer") |
||
85 | * @Assert\Choice(callback = "getStatuses") |
||
86 | * |
||
87 | * @var int |
||
88 | */ |
||
89 | protected $status = self::STATUS_DISABLED; |
||
90 | |||
91 | 27 | public function __construct() |
|
95 | |||
96 | /** |
||
97 | * @param string $command |
||
98 | * |
||
99 | * @return Task |
||
100 | */ |
||
101 | 1 | public function setCommand($command) |
|
106 | |||
107 | /** |
||
108 | * @return string |
||
109 | */ |
||
110 | 1 | public function getCommand() |
|
114 | |||
115 | /** |
||
116 | * @return int |
||
117 | */ |
||
118 | 1 | public function getId() |
|
122 | |||
123 | /** |
||
124 | * @param \DateTime $last_run |
||
125 | * |
||
126 | * @return Task |
||
127 | */ |
||
128 | 4 | public function setLastRun(\DateTime $last_run) |
|
133 | |||
134 | /** |
||
135 | * @return \DateTime|null |
||
136 | */ |
||
137 | 4 | public function getLastRun() |
|
141 | |||
142 | /** |
||
143 | * @param \DateTime $next_run |
||
144 | * |
||
145 | * @return Task |
||
146 | */ |
||
147 | 2 | public function setNextRun(\DateTime $next_run) |
|
152 | |||
153 | /** |
||
154 | * @return \DateTime |
||
155 | */ |
||
156 | 2 | public function getNextRun() |
|
160 | |||
161 | /** |
||
162 | * @param int $interval |
||
163 | * |
||
164 | * @return Task |
||
165 | */ |
||
166 | 3 | public function setInterval($interval) |
|
173 | |||
174 | /** |
||
175 | * @param string $modify |
||
176 | * |
||
177 | * @return Task |
||
178 | */ |
||
179 | 5 | public function setModify($modify) |
|
184 | |||
185 | /** |
||
186 | * @return string |
||
187 | */ |
||
188 | 9 | public function getModify() |
|
192 | |||
193 | /** |
||
194 | * @param int $status |
||
195 | * |
||
196 | * @return Task |
||
197 | */ |
||
198 | 4 | public function setStatus($status) |
|
203 | |||
204 | /** |
||
205 | * @return int |
||
206 | */ |
||
207 | 4 | public function getStatus() |
|
211 | |||
212 | /** |
||
213 | * @return int[] |
||
214 | */ |
||
215 | 1 | public static function getStatuses() |
|
222 | |||
223 | /** |
||
224 | * @param ExecutionContextInterface $context |
||
225 | */ |
||
226 | 2 | public function isModifyValid(ExecutionContextInterface $context) |
|
235 | |||
236 | /** |
||
237 | * Update task after execution |
||
238 | */ |
||
239 | 3 | public function executed() |
|
259 | } |
||
260 |