1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
6
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
7
|
|
|
use ControleOnline\Entity\ProductUnity; |
8
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
15
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
16
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter; |
|
|
|
|
17
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
18
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Product |
22
|
|
|
* |
23
|
|
|
* @ORM\Table(name="product", uniqueConstraints={@ORM\UniqueConstraint(name="company_id", columns={"company_id", "sku"})}, indexes={@ORM\Index(name="product_unit_id", columns={"product_unit_id"}), @ORM\Index(name="IDX_D34A04AD979B1AD6", columns={"company_id"})}) |
24
|
|
|
* @ORM\Entity(repositoryClass="ControleOnline\Repository\ProductRepository") |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
#[ApiResource( |
28
|
|
|
operations: [ |
29
|
|
|
new Get( |
30
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')', |
31
|
|
|
), |
32
|
|
|
new Put( |
33
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
34
|
|
|
denormalizationContext: ['groups' => ['product:write']] |
35
|
|
|
), |
36
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
37
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
38
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')') |
39
|
|
|
], |
40
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
41
|
|
|
normalizationContext: ['groups' => ['product:read']], |
42
|
|
|
denormalizationContext: ['groups' => ['product:write']] |
43
|
|
|
)] |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
class Product |
47
|
|
|
{ |
48
|
|
|
/** |
49
|
|
|
* @var int |
50
|
|
|
* |
51
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
52
|
|
|
* @ORM\Id |
53
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
54
|
|
|
* @Groups({"product_category:read","product:read","order_product:read"}) |
55
|
|
|
*/ |
56
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
57
|
|
|
|
58
|
|
|
private $id; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var string |
62
|
|
|
* |
63
|
|
|
* @ORM\Column(name="product", type="string", length=255, nullable=false) |
64
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
65
|
|
|
*/ |
66
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'partial'])] |
67
|
|
|
|
68
|
|
|
private $product; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @ORM\OneToMany(targetEntity="ProductFile", mappedBy="product") |
72
|
|
|
* @Groups({"product:read","product_category:read"}) |
73
|
|
|
*/ |
74
|
|
|
#[ApiFilter(filterClass: ExistsFilter::class, properties: ['productFiles'])] |
75
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productFiles.file.fileType' => 'exact'])] |
76
|
|
|
|
77
|
|
|
private $productFiles; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @ORM\OneToMany(targetEntity="ProductCategory", mappedBy="product") |
81
|
|
|
*/ |
82
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productCategory.category' => 'exact'])] |
83
|
|
|
|
84
|
|
|
private $productCategory; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var string|null |
88
|
|
|
* |
89
|
|
|
* @ORM\Column(name="sku", type="string", length=32, nullable=true, options={"default"="NULL"}) |
90
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
91
|
|
|
*/ |
92
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['sku' => 'partial'])] |
93
|
|
|
|
94
|
|
|
private $sku = NULL; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @var string |
98
|
|
|
* |
99
|
|
|
* @ORM\Column(name="type", type="string", length=0, nullable=false, options={"default"="'product'"}) |
100
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
101
|
|
|
*/ |
102
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['type' => 'exact'])] |
103
|
|
|
private $type = 'product'; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @var float |
107
|
|
|
* |
108
|
|
|
* @ORM\Column(name="price", type="float", precision=10, scale=0, nullable=false) |
109
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
110
|
|
|
*/ |
111
|
|
|
private $price = 0; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @var string |
115
|
|
|
* |
116
|
|
|
* @ORM\Column(name="product_condition", type="string", length=0, nullable=false, options={"default"="'new'"}) |
117
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
118
|
|
|
*/ |
119
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productCondition' => 'exact'])] |
120
|
|
|
|
121
|
|
|
private $productCondition = 'new'; |
122
|
|
|
|
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @var string |
126
|
|
|
* |
127
|
|
|
* @ORM\Column(name="description", type="string", length=0, nullable=false) |
128
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
129
|
|
|
*/ |
130
|
|
|
private $description = ''; |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @var bool |
135
|
|
|
* |
136
|
|
|
* @ORM\Column(name="featured", type="boolean", nullable=false, options={"default"="0"}) |
137
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
138
|
|
|
*/ |
139
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['featured' => 'exact'])] |
140
|
|
|
|
141
|
|
|
private $featured = false; |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @var bool |
145
|
|
|
* |
146
|
|
|
* @ORM\Column(name="active", type="boolean", nullable=false, options={"default"="1"}) |
147
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
148
|
|
|
*/ |
149
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['active' => 'exact'])] |
150
|
|
|
|
151
|
|
|
private $active = true; |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @var \ControleOnline\Entity\People |
155
|
|
|
* |
156
|
|
|
* @ORM\ManyToOne(targetEntity="\ControleOnline\Entity\People") |
157
|
|
|
* @ORM\JoinColumns({ |
158
|
|
|
* @ORM\JoinColumn(name="company_id", referencedColumnName="id") |
159
|
|
|
* }) |
160
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
161
|
|
|
*/ |
162
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['company' => 'exact'])] |
163
|
|
|
|
164
|
|
|
private $company; |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @var ProductUnity |
168
|
|
|
* |
169
|
|
|
* @ORM\ManyToOne(targetEntity="ProductUnity") |
170
|
|
|
* @ORM\JoinColumns({ |
171
|
|
|
* @ORM\JoinColumn(name="product_unit_id", referencedColumnName="id") |
172
|
|
|
* }) |
173
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
174
|
|
|
*/ |
175
|
|
|
private $productUnit; |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @var Queue |
|
|
|
|
179
|
|
|
* |
180
|
|
|
* @ORM\ManyToOne(targetEntity="Queue") |
181
|
|
|
* @ORM\JoinColumns({ |
182
|
|
|
* @ORM\JoinColumn(name="queue_id", referencedColumnName="id") |
183
|
|
|
* }) |
184
|
|
|
* @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"}) |
185
|
|
|
*/ |
186
|
|
|
private $queue; |
187
|
|
|
|
188
|
|
|
public function __construct() |
189
|
|
|
{ |
190
|
|
|
$this->productFiles = new \Doctrine\Common\Collections\ArrayCollection(); |
|
|
|
|
191
|
|
|
$this->productCategory = new \Doctrine\Common\Collections\ArrayCollection(); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Get the value of id |
196
|
|
|
*/ |
197
|
|
|
public function getId(): int |
198
|
|
|
{ |
199
|
|
|
return $this->id; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Set the value of id |
204
|
|
|
*/ |
205
|
|
|
public function setId(int $id): self |
206
|
|
|
{ |
207
|
|
|
$this->id = $id; |
208
|
|
|
|
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Get the value of product |
214
|
|
|
*/ |
215
|
|
|
public function getProduct(): string |
216
|
|
|
{ |
217
|
|
|
return $this->product; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Set the value of product |
222
|
|
|
*/ |
223
|
|
|
public function setProduct(string $product): self |
224
|
|
|
{ |
225
|
|
|
$this->product = $product; |
226
|
|
|
|
227
|
|
|
return $this; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* Get the value of sku |
232
|
|
|
*/ |
233
|
|
|
public function getSku(): ?string |
234
|
|
|
{ |
235
|
|
|
return $this->sku; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* Set the value of sku |
240
|
|
|
*/ |
241
|
|
|
public function setSku(?string $sku): self |
242
|
|
|
{ |
243
|
|
|
$this->sku = $sku; |
244
|
|
|
|
245
|
|
|
return $this; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* Get the value of type |
250
|
|
|
*/ |
251
|
|
|
public function getType(): string |
252
|
|
|
{ |
253
|
|
|
return $this->type; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Set the value of type |
258
|
|
|
*/ |
259
|
|
|
public function setType(string $type): self |
260
|
|
|
{ |
261
|
|
|
$this->type = $type; |
262
|
|
|
|
263
|
|
|
return $this; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* Get the value of price |
268
|
|
|
*/ |
269
|
|
|
public function getPrice(): float |
270
|
|
|
{ |
271
|
|
|
return $this->price; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Set the value of price |
276
|
|
|
*/ |
277
|
|
|
public function setPrice(float $price): self |
278
|
|
|
{ |
279
|
|
|
$this->price = $price; |
280
|
|
|
|
281
|
|
|
return $this; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Get the value of productCondition |
286
|
|
|
*/ |
287
|
|
|
public function getProductCondition(): string |
288
|
|
|
{ |
289
|
|
|
return $this->productCondition; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* Set the value of productCondition |
294
|
|
|
*/ |
295
|
|
|
public function setProductCondition(string $productCondition): self |
296
|
|
|
{ |
297
|
|
|
$this->productCondition = $productCondition; |
298
|
|
|
|
299
|
|
|
return $this; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* Get the value of active |
304
|
|
|
*/ |
305
|
|
|
public function isActive(): bool |
306
|
|
|
{ |
307
|
|
|
return $this->active; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* Set the value of active |
312
|
|
|
*/ |
313
|
|
|
public function setActive(bool $active): self |
314
|
|
|
{ |
315
|
|
|
$this->active = $active; |
316
|
|
|
|
317
|
|
|
return $this; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Get the value of company |
322
|
|
|
*/ |
323
|
|
|
public function getCompany(): ?People |
324
|
|
|
{ |
325
|
|
|
return $this->company; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* Set the value of company |
330
|
|
|
*/ |
331
|
|
|
public function setCompany(People $company): self |
332
|
|
|
{ |
333
|
|
|
$this->company = $company; |
334
|
|
|
|
335
|
|
|
return $this; |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
/** |
339
|
|
|
* Get the value of productUnit |
340
|
|
|
*/ |
341
|
|
|
public function getProductUnit(): ProductUnity |
342
|
|
|
{ |
343
|
|
|
return $this->productUnit; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Set the value of productUnit |
348
|
|
|
*/ |
349
|
|
|
public function setProductUnit(ProductUnity $productUnit): self |
350
|
|
|
{ |
351
|
|
|
$this->productUnit = $productUnit; |
352
|
|
|
|
353
|
|
|
return $this; |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
public function getActive(): ?bool |
357
|
|
|
{ |
358
|
|
|
return $this->active; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* Get the value of description |
363
|
|
|
*/ |
364
|
|
|
public function getDescription() |
365
|
|
|
{ |
366
|
|
|
return $this->description; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* Set the value of description |
371
|
|
|
*/ |
372
|
|
|
public function setDescription($description): self |
373
|
|
|
{ |
374
|
|
|
$this->description = $description; |
375
|
|
|
|
376
|
|
|
return $this; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Get the value of queue |
381
|
|
|
*/ |
382
|
|
|
public function getQueue() |
383
|
|
|
{ |
384
|
|
|
return $this->queue; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* Set the value of queue |
389
|
|
|
*/ |
390
|
|
|
public function setQueue($queue): self |
391
|
|
|
{ |
392
|
|
|
$this->queue = $queue; |
393
|
|
|
|
394
|
|
|
return $this; |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* @return Collection|ProductFile[] |
399
|
|
|
*/ |
400
|
|
|
public function getProductFiles(): Collection |
401
|
|
|
{ |
402
|
|
|
return $this->productFiles; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* @return Collection|ProductCategory[] |
407
|
|
|
*/ |
408
|
|
|
public function getProductCategory(): Collection |
409
|
|
|
{ |
410
|
|
|
return $this->productCategory; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* Get the value of featured |
415
|
|
|
*/ |
416
|
|
|
public function getFeatured() |
417
|
|
|
{ |
418
|
|
|
return $this->featured; |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
/** |
422
|
|
|
* Set the value of featured |
423
|
|
|
*/ |
424
|
|
|
public function setFeatured($featured): self |
425
|
|
|
{ |
426
|
|
|
$this->featured = $featured; |
427
|
|
|
|
428
|
|
|
return $this; |
429
|
|
|
} |
430
|
|
|
} |
431
|
|
|
|
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