|
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
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
|
|
20
|
|
|
use ControleOnline\Filter\RandomOrderFilter; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Product |
|
24
|
|
|
* |
|
25
|
|
|
* @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"})}) |
|
26
|
|
|
* @ORM\Entity(repositoryClass="ControleOnline\Repository\ProductRepository") |
|
27
|
|
|
*/ |
|
28
|
|
|
#[ApiResource( |
|
29
|
|
|
operations: [ |
|
30
|
|
|
new Get(security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')'), |
|
31
|
|
|
new Put(security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['product:write']]), |
|
32
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
|
33
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
|
34
|
|
|
new GetCollection(security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')'), |
|
35
|
|
|
], |
|
36
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
|
37
|
|
|
normalizationContext: ['groups' => ['product:read']], |
|
38
|
|
|
denormalizationContext: ['groups' => ['product:write']] |
|
39
|
|
|
)] |
|
40
|
|
|
#[ApiFilter(OrderFilter::class, properties: ['id' => 'ASC', 'product' => 'ASC', 'price' => 'DESC'])] |
|
41
|
|
|
#[ApiFilter(RandomOrderFilter::class)] |
|
42
|
|
|
class Product |
|
43
|
|
|
{ |
|
44
|
|
|
/** |
|
45
|
|
|
* @var int |
|
46
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
|
47
|
|
|
* @ORM\Id |
|
48
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
|
49
|
|
|
* @Groups({"product_category:read","product:read","order_product:read"}) |
|
50
|
|
|
*/ |
|
51
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
|
52
|
|
|
private $id; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var string |
|
56
|
|
|
* @ORM\Column(name="product", type="string", length=255, nullable=false) |
|
57
|
|
|
* @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"}) |
|
58
|
|
|
*/ |
|
59
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'partial'])] |
|
60
|
|
|
private $product; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @ORM\OneToMany(targetEntity="ProductFile", mappedBy="product") |
|
64
|
|
|
* @Groups({"product:read","product_category:read","order_product:read"}) |
|
65
|
|
|
*/ |
|
66
|
|
|
#[ApiFilter(filterClass: ExistsFilter::class, properties: ['productFiles'])] |
|
67
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productFiles.file.fileType' => 'exact'])] |
|
68
|
|
|
private $productFiles; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @ORM\OneToMany(targetEntity="ProductCategory", mappedBy="product") |
|
72
|
|
|
*/ |
|
73
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productCategory.category' => 'exact'])] |
|
74
|
|
|
private $productCategory; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @var string|null |
|
78
|
|
|
* @ORM\Column(name="sku", type="string", length=32, nullable=true, options={"default"="NULL"}) |
|
79
|
|
|
* @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"}) |
|
80
|
|
|
*/ |
|
81
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['sku' => 'partial'])] |
|
82
|
|
|
private $sku = null; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @var string |
|
86
|
|
|
* @ORM\Column(name="type", type="string", length=0, nullable=false, options={"default"="'product'"}) |
|
87
|
|
|
* @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"}) |
|
88
|
|
|
*/ |
|
89
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['type' => 'exact'])] |
|
90
|
|
|
private $type = 'product'; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @var float |
|
94
|
|
|
* @ORM\Column(name="price", type="float", precision=10, scale=0, nullable=false) |
|
95
|
|
|
* @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"}) |
|
96
|
|
|
*/ |
|
97
|
|
|
private $price = 0; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @var string |
|
101
|
|
|
* @ORM\Column(name="product_condition", type="string", length=0, nullable=false, options={"default"="'new'"}) |
|
102
|
|
|
* @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"}) |
|
103
|
|
|
*/ |
|
104
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productCondition' => 'exact'])] |
|
105
|
|
|
private $productCondition = 'new'; |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @var string |
|
109
|
|
|
* @ORM\Column(name="description", type="string", length=0, nullable=false) |
|
110
|
|
|
* @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"}) |
|
111
|
|
|
*/ |
|
112
|
|
|
private $description = ''; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @var bool |
|
116
|
|
|
* @ORM\Column(name="featured", type="boolean", nullable=false, options={"default"="0"}) |
|
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: ['featured' => 'exact'])] |
|
120
|
|
|
private $featured = false; |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @var bool |
|
124
|
|
|
* @ORM\Column(name="active", type="boolean", nullable=false, options={"default"="1"}) |
|
125
|
|
|
* @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"}) |
|
126
|
|
|
*/ |
|
127
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['active' => 'exact'])] |
|
128
|
|
|
private $active = true; |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @var \ControleOnline\Entity\People |
|
132
|
|
|
* @ORM\ManyToOne(targetEntity="\ControleOnline\Entity\People") |
|
133
|
|
|
* @ORM\JoinColumns({ |
|
134
|
|
|
* @ORM\JoinColumn(name="company_id", referencedColumnName="id") |
|
135
|
|
|
* }) |
|
136
|
|
|
* @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"}) |
|
137
|
|
|
*/ |
|
138
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['company' => 'exact'])] |
|
139
|
|
|
private $company; |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @var ProductUnity |
|
143
|
|
|
* @ORM\ManyToOne(targetEntity="ProductUnity") |
|
144
|
|
|
* @ORM\JoinColumns({ |
|
145
|
|
|
* @ORM\JoinColumn(name="product_unit_id", referencedColumnName="id") |
|
146
|
|
|
* }) |
|
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
|
|
|
private $productUnit; |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @var Queue |
|
|
|
|
|
|
153
|
|
|
* @ORM\ManyToOne(targetEntity="Queue") |
|
154
|
|
|
* @ORM\JoinColumns({ |
|
155
|
|
|
* @ORM\JoinColumn(name="queue_id", referencedColumnName="id") |
|
156
|
|
|
* }) |
|
157
|
|
|
* @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"}) |
|
158
|
|
|
*/ |
|
159
|
|
|
private $queue; |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @ORM\OneToMany(targetEntity="ProductGroupProduct", mappedBy="product") |
|
163
|
|
|
* @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"}) |
|
164
|
|
|
*/ |
|
165
|
|
|
private $productGroupProducts; |
|
166
|
|
|
|
|
167
|
|
|
public function __construct() |
|
168
|
|
|
{ |
|
169
|
|
|
$this->productFiles = new \Doctrine\Common\Collections\ArrayCollection(); |
|
|
|
|
|
|
170
|
|
|
$this->productCategory = new \Doctrine\Common\Collections\ArrayCollection(); |
|
171
|
|
|
$this->productGroupProducts = new \Doctrine\Common\Collections\ArrayCollection(); |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
public function getId() |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->id; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
public function setId($id): self |
|
180
|
|
|
{ |
|
181
|
|
|
$this->id = $id; |
|
182
|
|
|
return $this; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
public function getProduct(): string |
|
186
|
|
|
{ |
|
187
|
|
|
return $this->product; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
public function setProduct(string $product): self |
|
191
|
|
|
{ |
|
192
|
|
|
$this->product = $product; |
|
193
|
|
|
return $this; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
public function getSku(): ?string |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->sku; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
public function setSku(?string $sku): self |
|
202
|
|
|
{ |
|
203
|
|
|
$this->sku = $sku; |
|
204
|
|
|
return $this; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
public function getType(): string |
|
208
|
|
|
{ |
|
209
|
|
|
return $this->type; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
public function setType(string $type): self |
|
213
|
|
|
{ |
|
214
|
|
|
$this->type = $type; |
|
215
|
|
|
return $this; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
public function getPrice(): float |
|
219
|
|
|
{ |
|
220
|
|
|
return $this->price; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
public function setPrice(float $price): self |
|
224
|
|
|
{ |
|
225
|
|
|
$this->price = $price; |
|
226
|
|
|
return $this; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
public function getProductCondition(): string |
|
230
|
|
|
{ |
|
231
|
|
|
return $this->productCondition; |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
public function setProductCondition(string $productCondition): self |
|
235
|
|
|
{ |
|
236
|
|
|
$this->productCondition = $productCondition; |
|
237
|
|
|
return $this; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
public function isActive(): bool |
|
241
|
|
|
{ |
|
242
|
|
|
return $this->active; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
public function setActive(bool $active): self |
|
246
|
|
|
{ |
|
247
|
|
|
$this->active = $active; |
|
248
|
|
|
return $this; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
public function getCompany(): ?People |
|
252
|
|
|
{ |
|
253
|
|
|
return $this->company; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
public function setCompany(People $company): self |
|
257
|
|
|
{ |
|
258
|
|
|
$this->company = $company; |
|
259
|
|
|
return $this; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
public function getProductUnit(): ProductUnity |
|
263
|
|
|
{ |
|
264
|
|
|
return $this->productUnit; |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
public function setProductUnit(ProductUnity $productUnit): self |
|
268
|
|
|
{ |
|
269
|
|
|
$this->productUnit = $productUnit; |
|
270
|
|
|
return $this; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
public function getDescription(): string |
|
274
|
|
|
{ |
|
275
|
|
|
return $this->description; |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
public function setDescription(string $description): self |
|
279
|
|
|
{ |
|
280
|
|
|
$this->description = $description; |
|
281
|
|
|
return $this; |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
public function getQueue() |
|
285
|
|
|
{ |
|
286
|
|
|
return $this->queue; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
public function setQueue($queue): self |
|
290
|
|
|
{ |
|
291
|
|
|
$this->queue = $queue; |
|
292
|
|
|
return $this; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
public function getProductFiles(): Collection |
|
296
|
|
|
{ |
|
297
|
|
|
return $this->productFiles; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
public function getProductCategory(): Collection |
|
301
|
|
|
{ |
|
302
|
|
|
return $this->productCategory; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
public function getFeatured(): bool |
|
306
|
|
|
{ |
|
307
|
|
|
return $this->featured; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
public function setFeatured(bool $featured): self |
|
311
|
|
|
{ |
|
312
|
|
|
$this->featured = $featured; |
|
313
|
|
|
return $this; |
|
314
|
|
|
} |
|
315
|
|
|
|
|
316
|
|
|
public function getProductGroupProducts(): Collection |
|
317
|
|
|
{ |
|
318
|
|
|
return $this->productGroupProducts; |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
|
|
322
|
|
|
public function addProductGroupProduct(ProductGroupProduct $productGroupProduct): self |
|
323
|
|
|
{ |
|
324
|
|
|
if (!$this->productGroupProducts->contains($productGroupProduct)) { |
|
325
|
|
|
$this->productGroupProducts[] = $productGroupProduct; |
|
326
|
|
|
$productGroupProduct->setProduct($this); |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
return $this; |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
|
|
333
|
|
|
public function removeProductGroupProduct(ProductGroupProduct $productGroupProduct): self |
|
334
|
|
|
{ |
|
335
|
|
|
$this->productGroupProducts->removeElement($productGroupProduct); |
|
336
|
|
|
return $this; |
|
337
|
|
|
} |
|
338
|
|
|
} |
|
339
|
|
|
|
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