|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Patch; |
|
|
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
|
|
15
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
|
|
16
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
|
|
17
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
|
18
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
|
|
19
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
|
|
20
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
|
|
21
|
|
|
use ControleOnline\Entity\Status; |
|
|
|
|
|
|
22
|
|
|
use ControleOnline\Entity\Category; |
|
|
|
|
|
|
23
|
|
|
use ControleOnline\Entity\Order; |
|
|
|
|
|
|
24
|
|
|
use ControleOnline\Repository\TaskRepository; |
|
25
|
|
|
use ControleOnline\Listener\LogListener; |
|
|
|
|
|
|
26
|
|
|
use DateTime; |
|
27
|
|
|
use DateTimeInterface; |
|
28
|
|
|
use stdClass; |
|
29
|
|
|
|
|
30
|
|
|
#[ORM\Table(name: 'tasks')] |
|
31
|
|
|
#[ORM\EntityListeners([LogListener::class])] |
|
32
|
|
|
#[ORM\Entity(repositoryClass: TaskRepository::class)] |
|
33
|
|
|
#[ApiResource( |
|
34
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => 'text/csv'], |
|
35
|
|
|
normalizationContext: ['groups' => ['task:read']], |
|
36
|
|
|
denormalizationContext: ['groups' => ['task:write']], |
|
37
|
|
|
security: "is_granted('ROLE_CLIENT')", |
|
38
|
|
|
operations: [ |
|
39
|
|
|
new GetCollection( |
|
40
|
|
|
security: "is_granted('ROLE_CLIENT')", |
|
41
|
|
|
uriTemplate: '/tasks' |
|
42
|
|
|
), |
|
43
|
|
|
new Get(security: "is_granted('ROLE_CLIENT')"), |
|
44
|
|
|
new Post(security: "is_granted('ROLE_CLIENT')"), |
|
45
|
|
|
new Put(security: "is_granted('ROLE_CLIENT')"), |
|
46
|
|
|
new Patch(security: "is_granted('ROLE_CLIENT')"), |
|
47
|
|
|
new Delete(security: "is_granted('ROLE_CLIENT')") |
|
48
|
|
|
] |
|
49
|
|
|
)] |
|
50
|
|
|
#[ApiFilter(OrderFilter::class, properties: ['dueDate' => 'ASC', 'alterDate' => 'DESC'])] |
|
51
|
|
|
#[ApiFilter(SearchFilter::class, properties: [ |
|
52
|
|
|
'provider' => 'exact', |
|
53
|
|
|
'taskFor' => 'exact', |
|
54
|
|
|
'registeredBy' => 'exact', |
|
55
|
|
|
'taskStatus' => 'exact', |
|
56
|
|
|
'reason' => 'exact', |
|
57
|
|
|
'criticality' => 'exact', |
|
58
|
|
|
'category' => 'exact', |
|
59
|
|
|
'client' => 'exact', |
|
60
|
|
|
'order' => 'exact', |
|
61
|
|
|
'type' => 'exact' |
|
62
|
|
|
])] |
|
63
|
|
|
class Task |
|
64
|
|
|
{ |
|
65
|
|
|
#[ORM\Column(type: 'integer', nullable: false)] |
|
66
|
|
|
#[ORM\Id] |
|
67
|
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')] |
|
68
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
69
|
|
|
private $id; |
|
70
|
|
|
|
|
71
|
|
|
#[ORM\Column(name: 'name', type: 'string', length: 50, nullable: false)] |
|
72
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
73
|
|
|
private $name; |
|
74
|
|
|
|
|
75
|
|
|
#[ORM\Column(name: 'task_type', type: 'string', length: 50, nullable: true)] |
|
76
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
77
|
|
|
private $type; |
|
78
|
|
|
|
|
79
|
|
|
#[ORM\Column(name: 'due_date', type: 'datetime', nullable: true, columnDefinition: 'DATETIME')] |
|
80
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
81
|
|
|
private $dueDate; |
|
82
|
|
|
|
|
83
|
|
|
#[ORM\ManyToOne(targetEntity: People::class)] |
|
84
|
|
|
#[ORM\JoinColumn(name: 'registered_by_id', referencedColumnName: 'id', nullable: false)] |
|
85
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
86
|
|
|
private $registeredBy; |
|
87
|
|
|
|
|
88
|
|
|
#[ORM\ManyToOne(targetEntity: People::class)] |
|
89
|
|
|
#[ORM\JoinColumn(name: 'task_for_id', referencedColumnName: 'id', nullable: true)] |
|
90
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
91
|
|
|
private $taskFor; |
|
92
|
|
|
|
|
93
|
|
|
#[ORM\ManyToOne(targetEntity: People::class)] |
|
94
|
|
|
#[ORM\JoinColumn(name: 'client_id', referencedColumnName: 'id', nullable: true)] |
|
95
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
96
|
|
|
private $client; |
|
97
|
|
|
|
|
98
|
|
|
#[ORM\ManyToOne(targetEntity: Status::class)] |
|
99
|
|
|
#[ORM\JoinColumn(name: 'task_status_id', referencedColumnName: 'id', nullable: false)] |
|
100
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
101
|
|
|
private $taskStatus; |
|
102
|
|
|
|
|
103
|
|
|
#[ORM\ManyToOne(targetEntity: Category::class)] |
|
104
|
|
|
#[ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id', nullable: true)] |
|
105
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
106
|
|
|
private $category; |
|
107
|
|
|
|
|
108
|
|
|
#[ORM\ManyToOne(targetEntity: Category::class)] |
|
109
|
|
|
#[ORM\JoinColumn(name: 'reason_id', referencedColumnName: 'id', nullable: true)] |
|
110
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
111
|
|
|
private $reason; |
|
112
|
|
|
|
|
113
|
|
|
#[ORM\ManyToOne(targetEntity: Category::class)] |
|
114
|
|
|
#[ORM\JoinColumn(name: 'criticality_id', referencedColumnName: 'id', nullable: true)] |
|
115
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
116
|
|
|
private $criticality; |
|
117
|
|
|
|
|
118
|
|
|
#[ORM\ManyToOne(targetEntity: People::class)] |
|
119
|
|
|
#[ORM\JoinColumn(name: 'provider_id', referencedColumnName: 'id', nullable: false)] |
|
120
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
121
|
|
|
private $provider; |
|
122
|
|
|
|
|
123
|
|
|
#[ORM\ManyToOne(targetEntity: Order::class, inversedBy: 'task')] |
|
124
|
|
|
#[ORM\JoinColumn(name: 'order_id', referencedColumnName: 'id', nullable: true)] |
|
125
|
|
|
#[Groups(['task:read'])] |
|
126
|
|
|
private $order; |
|
127
|
|
|
|
|
128
|
|
|
#[ORM\Column(name: 'created_at', type: 'datetime', nullable: false, columnDefinition: 'DATETIME')] |
|
129
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
130
|
|
|
private $createdAt; |
|
131
|
|
|
|
|
132
|
|
|
#[ORM\Column(name: 'alter_date', type: 'datetime', nullable: true, columnDefinition: 'DATETIME')] |
|
133
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
134
|
|
|
private $alterDate; |
|
135
|
|
|
|
|
136
|
|
|
#[ORM\Column(name: 'announce', type: 'string', nullable: true)] |
|
137
|
|
|
#[Groups(['task:write', 'task:read', 'order:read'])] |
|
138
|
|
|
private string $announce; |
|
139
|
|
|
|
|
140
|
|
|
public function __construct() |
|
141
|
|
|
{ |
|
142
|
|
|
$this->createdAt = new DateTime('now'); |
|
143
|
|
|
$this->alterDate = new DateTime('now'); |
|
144
|
|
|
$this->announce = json_encode(new stdClass()); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
public function getId() |
|
148
|
|
|
{ |
|
149
|
|
|
return $this->id; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function getName() |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->name; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
public function setName($name): self |
|
158
|
|
|
{ |
|
159
|
|
|
$this->name = $name; |
|
160
|
|
|
return $this; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
public function getType() |
|
164
|
|
|
{ |
|
165
|
|
|
return $this->type; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
public function setType($type): self |
|
169
|
|
|
{ |
|
170
|
|
|
$this->type = $type; |
|
171
|
|
|
return $this; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
public function getDueDate() |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->dueDate; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
public function setDueDate($dueDate): self |
|
180
|
|
|
{ |
|
181
|
|
|
$this->dueDate = $dueDate; |
|
182
|
|
|
return $this; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
public function getRegisteredBy() |
|
186
|
|
|
{ |
|
187
|
|
|
return $this->registeredBy; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
public function setRegisteredBy($registeredBy): self |
|
191
|
|
|
{ |
|
192
|
|
|
$this->registeredBy = $registeredBy; |
|
193
|
|
|
return $this; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
public function getTaskFor() |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->taskFor; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
public function setTaskFor($taskFor): self |
|
202
|
|
|
{ |
|
203
|
|
|
$this->taskFor = $taskFor; |
|
204
|
|
|
return $this; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
public function getClient() |
|
208
|
|
|
{ |
|
209
|
|
|
return $this->client; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
public function setClient($client): self |
|
213
|
|
|
{ |
|
214
|
|
|
$this->client = $client; |
|
215
|
|
|
return $this; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
public function getTaskStatus() |
|
219
|
|
|
{ |
|
220
|
|
|
return $this->taskStatus; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
public function setTaskStatus($taskStatus): self |
|
224
|
|
|
{ |
|
225
|
|
|
$this->taskStatus = $taskStatus; |
|
226
|
|
|
return $this; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
public function getCategory() |
|
230
|
|
|
{ |
|
231
|
|
|
return $this->category; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
public function setCategory($category): self |
|
235
|
|
|
{ |
|
236
|
|
|
$this->category = $category; |
|
237
|
|
|
return $this; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
public function getReason() |
|
241
|
|
|
{ |
|
242
|
|
|
return $this->reason; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
public function setReason($reason): self |
|
246
|
|
|
{ |
|
247
|
|
|
$this->reason = $reason; |
|
248
|
|
|
return $this; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
public function getCriticality() |
|
252
|
|
|
{ |
|
253
|
|
|
return $this->criticality; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
public function setCriticality($criticality): self |
|
257
|
|
|
{ |
|
258
|
|
|
$this->criticality = $criticality; |
|
259
|
|
|
return $this; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
public function getProvider() |
|
263
|
|
|
{ |
|
264
|
|
|
return $this->provider; |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
public function setProvider($provider): self |
|
268
|
|
|
{ |
|
269
|
|
|
$this->provider = $provider; |
|
270
|
|
|
return $this; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
public function getOrder() |
|
274
|
|
|
{ |
|
275
|
|
|
return $this->order; |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
public function setOrder($order): self |
|
279
|
|
|
{ |
|
280
|
|
|
$this->order = $order; |
|
281
|
|
|
return $this; |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
public function getCreatedAt() |
|
285
|
|
|
{ |
|
286
|
|
|
return $this->createdAt; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
public function getAlterDate() |
|
290
|
|
|
{ |
|
291
|
|
|
return $this->alterDate; |
|
292
|
|
|
} |
|
293
|
|
|
public function getAnnounce(bool $decode = false): string|array |
|
294
|
|
|
{ |
|
295
|
|
|
// Ensure we're decoding a string, even if it was temporarily an array internally |
|
296
|
|
|
$announceString = is_array($this->announce) ? json_encode($this->announce) : $this->announce; |
|
|
|
|
|
|
297
|
|
|
return $decode ? json_decode((string) $announceString, true) : (string) $announceString; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
public function addAnnounce(mixed $value): self |
|
301
|
|
|
{ |
|
302
|
|
|
$announce = $this->getAnnounce(true); |
|
303
|
|
|
|
|
304
|
|
|
if (!in_array($value, $announce)) |
|
|
|
|
|
|
305
|
|
|
array_push($announce, $value); |
|
|
|
|
|
|
306
|
|
|
|
|
307
|
|
|
return $this->setAnnounce($announce); |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
public function setAnnounce(string|array|object $announce): self |
|
311
|
|
|
{ |
|
312
|
|
|
if (is_string($announce)) |
|
|
|
|
|
|
313
|
|
|
$announce = json_decode($announce, true); |
|
314
|
|
|
|
|
315
|
|
|
$this->announce = json_encode($announce); |
|
316
|
|
|
return $this; |
|
317
|
|
|
} |
|
318
|
|
|
} |
|
319
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths