1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
6
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
9
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
13
|
|
|
use ControleOnline\Controller\GenerateContractController; |
14
|
|
|
use DateTime; |
15
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
16
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
17
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class}) |
21
|
|
|
* @ORM\Entity (repositoryClass="ControleOnline\Repository\ContractRepository") |
22
|
|
|
*/ |
23
|
|
|
#[ApiResource( |
24
|
|
|
operations: [ |
25
|
|
|
new Get(security: 'is_granted(\'ROLE_CLIENT\')'), |
26
|
|
|
new Put(security: 'is_granted(\'ROLE_CLIENT\')'), |
27
|
|
|
new Post(), |
28
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'), |
29
|
|
|
new Post( |
30
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
31
|
|
|
uriTemplate: '/contracts/{id}/generate', |
32
|
|
|
controller: GenerateContractController::class, |
33
|
|
|
deserialize: false |
34
|
|
|
), |
35
|
|
|
], |
36
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
37
|
|
|
normalizationContext: ['groups' => ['contract_read']], |
38
|
|
|
denormalizationContext: ['groups' => ['contract_write']] |
39
|
|
|
)] |
40
|
|
|
class Contract |
41
|
|
|
{ |
42
|
|
|
/** |
43
|
|
|
* @ORM\Column(type="integer", nullable=false) |
44
|
|
|
* @ORM\Id |
45
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
46
|
|
|
* @Groups({ "contract_read"}) |
47
|
|
|
*/ |
48
|
|
|
private $id; |
49
|
|
|
/** |
50
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Model") |
51
|
|
|
* @ORM\JoinColumns({ |
52
|
|
|
* @ORM\JoinColumn(referencedColumnName="id", nullable=false) |
53
|
|
|
* }) |
54
|
|
|
* @Groups({"contract_read","contract_write"}) |
55
|
|
|
*/ |
56
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['contractModel' => 'exact'])] |
57
|
|
|
|
58
|
|
|
private $contractModel; |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var \ControleOnline\Entity\Status |
|
|
|
|
63
|
|
|
* |
64
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Status") |
65
|
|
|
* @ORM\JoinColumns({ |
66
|
|
|
* @ORM\JoinColumn(name="status_id", referencedColumnName="id") |
67
|
|
|
* }) |
68
|
|
|
* @Groups({"contract_read","contract_write"}) |
69
|
|
|
*/ |
70
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['status' => 'exact'])] |
71
|
|
|
|
72
|
|
|
private $status; |
73
|
|
|
/** |
74
|
|
|
* @ORM\Column(name="doc_key", type="string") |
75
|
|
|
* @Groups({"contract_read","contract_write"}) |
76
|
|
|
*/ |
77
|
|
|
private $docKey; |
78
|
|
|
/** |
79
|
|
|
* @ORM\Column(name="start_date", type="datetime", nullable=false) |
80
|
|
|
* @Groups({"contract_read","contract_write"}) |
81
|
|
|
*/ |
82
|
|
|
private $startDate; |
83
|
|
|
/** |
84
|
|
|
* @ORM\Column(name="end_date", type="datetime", nullable=true) |
85
|
|
|
* @Groups({"contract_read","contract_write"}) |
86
|
|
|
*/ |
87
|
|
|
private $endDate; |
88
|
|
|
/** |
89
|
|
|
* @ORM\Column(name="creation_date", type="datetime", nullable=false) |
90
|
|
|
* @Groups({"contract_read","contract_write"}) |
91
|
|
|
*/ |
92
|
|
|
private $creationDate; |
93
|
|
|
/** |
94
|
|
|
* @ORM\Column(name="alter_date", type="datetime", nullable=false) |
95
|
|
|
* @Groups({"contract_read","contract_write"}) |
96
|
|
|
*/ |
97
|
|
|
private $alterDate; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File") |
101
|
|
|
* @ORM\JoinColumns({ |
102
|
|
|
* @ORM\JoinColumn(referencedColumnName="id", nullable=true) |
103
|
|
|
* }) |
104
|
|
|
* @Groups({"contract_read","contract_write"}) |
105
|
|
|
*/ |
106
|
|
|
private $contractFile; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @var \ControleOnline\Entity\People |
|
|
|
|
110
|
|
|
* |
111
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
112
|
|
|
* @ORM\JoinColumns({ |
113
|
|
|
* @ORM\JoinColumn(name="beneficiary_id", referencedColumnName="id") |
114
|
|
|
* }) |
115
|
|
|
* @Groups({"contract_read","contract_write"}) |
116
|
|
|
*/ |
117
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['beneficiary' => 'exact'])] |
118
|
|
|
|
119
|
|
|
private $beneficiary; |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Many Contracts have Many Peoples. |
123
|
|
|
* |
124
|
|
|
* @ORM\OneToMany(targetEntity="ControleOnline\Entity\ContractPeople", mappedBy="contract") |
125
|
|
|
* @Groups({"contract_read","contract_write"}) |
126
|
|
|
*/ |
127
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['peoples' => 'exact'])] |
128
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['peoples.people.name' => 'partial'])] |
129
|
|
|
|
130
|
|
|
private $peoples; |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
public function __construct() |
134
|
|
|
{ |
135
|
|
|
$this->startDate = new DateTime('now'); |
136
|
|
|
$this->endDate = new DateTime('now'); |
137
|
|
|
$this->creationDate = new DateTime('now'); |
138
|
|
|
$this->alterDate = new DateTime('now'); |
139
|
|
|
} |
140
|
|
|
public function getId(): int |
141
|
|
|
{ |
142
|
|
|
return $this->id; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Set status |
147
|
|
|
* |
148
|
|
|
* @param \ControleOnline\Entity\Status $status |
149
|
|
|
* @return Status |
150
|
|
|
*/ |
151
|
|
|
public function setStatus(\ControleOnline\Entity\Status $status = null) |
152
|
|
|
{ |
153
|
|
|
$this->status = $status; |
154
|
|
|
|
155
|
|
|
return $this; |
|
|
|
|
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Get status |
160
|
|
|
* |
161
|
|
|
* @return \ControleOnline\Entity\Status |
162
|
|
|
*/ |
163
|
|
|
public function getStatus() |
164
|
|
|
{ |
165
|
|
|
return $this->status; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function getStartDate(): DateTime |
169
|
|
|
{ |
170
|
|
|
return $this->startDate; |
171
|
|
|
} |
172
|
|
|
public function setStartDate(DateTime $start_date): Contract |
173
|
|
|
{ |
174
|
|
|
$this->startDate = $start_date; |
175
|
|
|
return $this; |
176
|
|
|
} |
177
|
|
|
public function getEndDate(): ?DateTime |
178
|
|
|
{ |
179
|
|
|
return $this->endDate; |
180
|
|
|
} |
181
|
|
|
public function setEndDate(?DateTime $end_date): Contract |
182
|
|
|
{ |
183
|
|
|
$this->endDate = $end_date; |
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
public function getCreationDate(): DateTime |
187
|
|
|
{ |
188
|
|
|
return $this->creationDate; |
189
|
|
|
} |
190
|
|
|
public function setCreationDate(DateTime $creation_date): Contract |
191
|
|
|
{ |
192
|
|
|
$this->creationDate = $creation_date; |
193
|
|
|
return $this; |
194
|
|
|
} |
195
|
|
|
public function getAlterDate(): DateTime |
196
|
|
|
{ |
197
|
|
|
return $this->alterDate; |
198
|
|
|
} |
199
|
|
|
public function setAlterDate(DateTime $alter_date): Contract |
200
|
|
|
{ |
201
|
|
|
$this->alterDate = $alter_date; |
202
|
|
|
return $this; |
203
|
|
|
} |
204
|
|
|
/** |
205
|
|
|
* @return mixed |
206
|
|
|
*/ |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Get }) |
210
|
|
|
*/ |
211
|
|
|
public function getContractFile() |
212
|
|
|
{ |
213
|
|
|
return $this->contractFile; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* Set }) |
218
|
|
|
*/ |
219
|
|
|
public function setContractFile($contractFile): self |
220
|
|
|
{ |
221
|
|
|
$this->contractFile = $contractFile; |
222
|
|
|
|
223
|
|
|
return $this; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Get the value of beneficiary |
228
|
|
|
*/ |
229
|
|
|
public function getBeneficiary() |
230
|
|
|
{ |
231
|
|
|
return $this->beneficiary; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Set the value of beneficiary |
236
|
|
|
*/ |
237
|
|
|
public function setBeneficiary($beneficiary): self |
238
|
|
|
{ |
239
|
|
|
$this->beneficiary = $beneficiary; |
240
|
|
|
|
241
|
|
|
return $this; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Get }) |
246
|
|
|
*/ |
247
|
|
|
public function getContractModel() |
248
|
|
|
{ |
249
|
|
|
return $this->contractModel; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Set }) |
254
|
|
|
*/ |
255
|
|
|
public function setContractModel($contractModel): self |
256
|
|
|
{ |
257
|
|
|
$this->contractModel = $contractModel; |
258
|
|
|
|
259
|
|
|
return $this; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* Add peoples. |
265
|
|
|
* |
266
|
|
|
* @return Peoples |
|
|
|
|
267
|
|
|
*/ |
268
|
|
|
public function addPeoples(ContractPeople $peoples) |
269
|
|
|
{ |
270
|
|
|
$this->peoples[] = $peoples; |
271
|
|
|
return $this; |
|
|
|
|
272
|
|
|
} |
273
|
|
|
/** |
274
|
|
|
* Remove peoples. |
275
|
|
|
*/ |
276
|
|
|
public function removePeoples(ContractPeople $peoples) |
277
|
|
|
{ |
278
|
|
|
$this->peoples->removeElement($peoples); |
279
|
|
|
} |
280
|
|
|
/** |
281
|
|
|
* Get peoples. |
282
|
|
|
* |
283
|
|
|
* @return Collection |
284
|
|
|
*/ |
285
|
|
|
public function getPeoples() |
286
|
|
|
{ |
287
|
|
|
return $this->peoples; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* Get the value of docKey |
292
|
|
|
*/ |
293
|
|
|
public function getDocKey() |
294
|
|
|
{ |
295
|
|
|
return $this->docKey; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* Set the value of docKey |
300
|
|
|
*/ |
301
|
|
|
public function setDocKey($docKey): self |
302
|
|
|
{ |
303
|
|
|
$this->docKey = $docKey; |
304
|
|
|
|
305
|
|
|
return $this; |
306
|
|
|
} |
307
|
|
|
} |
308
|
|
|
|
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