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