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
|
|
|
public function __construct() |
163
|
|
|
{ |
164
|
|
|
$this->productFiles = new \Doctrine\Common\Collections\ArrayCollection(); |
|
|
|
|
165
|
|
|
$this->productCategory = new \Doctrine\Common\Collections\ArrayCollection(); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function getId() |
169
|
|
|
{ |
170
|
|
|
return $this->id; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function setId($id): self |
174
|
|
|
{ |
175
|
|
|
$this->id = $id; |
176
|
|
|
return $this; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
public function getProduct(): string |
180
|
|
|
{ |
181
|
|
|
return $this->product; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public function setProduct(string $product): self |
185
|
|
|
{ |
186
|
|
|
$this->product = $product; |
187
|
|
|
return $this; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
public function getSku(): ?string |
191
|
|
|
{ |
192
|
|
|
return $this->sku; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function setSku(?string $sku): self |
196
|
|
|
{ |
197
|
|
|
$this->sku = $sku; |
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
public function getType(): string |
202
|
|
|
{ |
203
|
|
|
return $this->type; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
public function setType(string $type): self |
207
|
|
|
{ |
208
|
|
|
$this->type = $type; |
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
public function getPrice(): float |
213
|
|
|
{ |
214
|
|
|
return $this->price; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function setPrice(float $price): self |
218
|
|
|
{ |
219
|
|
|
$this->price = $price; |
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
public function getProductCondition(): string |
224
|
|
|
{ |
225
|
|
|
return $this->productCondition; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function setProductCondition(string $productCondition): self |
229
|
|
|
{ |
230
|
|
|
$this->productCondition = $productCondition; |
231
|
|
|
return $this; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
public function isActive(): bool |
235
|
|
|
{ |
236
|
|
|
return $this->active; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
public function setActive(bool $active): self |
240
|
|
|
{ |
241
|
|
|
$this->active = $active; |
242
|
|
|
return $this; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
public function getCompany(): ?People |
246
|
|
|
{ |
247
|
|
|
return $this->company; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
public function setCompany(People $company): self |
251
|
|
|
{ |
252
|
|
|
$this->company = $company; |
253
|
|
|
return $this; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
public function getProductUnit(): ProductUnity |
257
|
|
|
{ |
258
|
|
|
return $this->productUnit; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
public function setProductUnit(ProductUnity $productUnit): self |
262
|
|
|
{ |
263
|
|
|
$this->productUnit = $productUnit; |
264
|
|
|
return $this; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
public function getDescription(): string |
268
|
|
|
{ |
269
|
|
|
return $this->description; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
public function setDescription(string $description): self |
273
|
|
|
{ |
274
|
|
|
$this->description = $description; |
275
|
|
|
return $this; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
public function getQueue() |
279
|
|
|
{ |
280
|
|
|
return $this->queue; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
public function setQueue($queue): self |
284
|
|
|
{ |
285
|
|
|
$this->queue = $queue; |
286
|
|
|
return $this; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
public function getProductFiles(): Collection |
290
|
|
|
{ |
291
|
|
|
return $this->productFiles; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
public function getProductCategory(): Collection |
295
|
|
|
{ |
296
|
|
|
return $this->productCategory; |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
public function getFeatured(): bool |
300
|
|
|
{ |
301
|
|
|
return $this->featured; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
public function setFeatured(bool $featured): self |
305
|
|
|
{ |
306
|
|
|
$this->featured = $featured; |
307
|
|
|
return $this; |
308
|
|
|
} |
309
|
|
|
} |
310
|
|
|
|
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