|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter; |
|
|
|
|
|
|
8
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
|
|
9
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
|
|
15
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
|
|
16
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
|
|
17
|
|
|
use ControleOnline\Filter\RandomOrderFilter; |
|
|
|
|
|
|
18
|
|
|
use ControleOnline\Listener\LogListener; |
|
|
|
|
|
|
19
|
|
|
use ControleOnline\Repository\ProductRepository; |
|
20
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
|
|
21
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
|
|
22
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
#[ApiResource( |
|
25
|
|
|
operations: [ |
|
26
|
|
|
new Get(security: 'is_granted(\'PUBLIC_ACCESS\')'), |
|
27
|
|
|
new Put(security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['product:write']]), |
|
28
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
|
29
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
|
30
|
|
|
new GetCollection(security: 'is_granted(\'PUBLIC_ACCESS\')'), |
|
31
|
|
|
], |
|
32
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
|
33
|
|
|
normalizationContext: ['groups' => ['product:read']], |
|
34
|
|
|
denormalizationContext: ['groups' => ['product:write']] |
|
35
|
|
|
)] |
|
36
|
|
|
#[ApiFilter(OrderFilter::class, properties: ['product', 'price', 'description'])] |
|
37
|
|
|
#[ApiFilter(RandomOrderFilter::class)] |
|
38
|
|
|
#[ORM\Table(name: 'product')] |
|
39
|
|
|
#[ORM\Index(name: 'product_unity_id', columns: ['product_unity_id'])] |
|
40
|
|
|
#[ORM\Index(name: 'IDX_D34A04AD979B1AD6', columns: ['company_id'])] |
|
41
|
|
|
#[ORM\Index(name: 'default_out_inventory_id', columns: ['default_out_inventory_id'])] |
|
42
|
|
|
#[ORM\Index(name: 'default_in_inventory_id', columns: ['default_in_inventory_id'])] |
|
43
|
|
|
#[ORM\UniqueConstraint(name: 'company_id', columns: ['company_id', 'sku'])] |
|
44
|
|
|
#[ORM\Entity(repositoryClass: ProductRepository::class)] |
|
45
|
|
|
class Product |
|
46
|
|
|
{ |
|
47
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
|
48
|
|
|
#[ORM\Column(name: 'id', type: 'integer', nullable: false)] |
|
49
|
|
|
#[ORM\Id] |
|
50
|
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')] |
|
51
|
|
|
#[Groups(['product_category:read', 'product:read', 'order_product:read'])] |
|
52
|
|
|
private $id; |
|
53
|
|
|
|
|
54
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'partial'])] |
|
55
|
|
|
#[ORM\Column(name: 'product', type: 'string', length: 255, nullable: true)] |
|
56
|
|
|
#[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'])] |
|
57
|
|
|
private $product; |
|
58
|
|
|
|
|
59
|
|
|
#[ApiFilter(filterClass: ExistsFilter::class, properties: ['productFiles'])] |
|
60
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productFiles.file.fileType' => 'exact'])] |
|
61
|
|
|
#[ORM\OneToMany(targetEntity: ProductFile::class, mappedBy: 'product')] |
|
62
|
|
|
#[Groups(['product:read', 'product_category:read','order_details:read', 'order:write', 'order_product:read'])] |
|
63
|
|
|
private $productFiles; |
|
64
|
|
|
|
|
65
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productCategory.category' => 'exact'])] |
|
66
|
|
|
#[ORM\OneToMany(targetEntity: ProductCategory::class, mappedBy: 'product')] |
|
67
|
|
|
private $productCategory; |
|
68
|
|
|
|
|
69
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['sku' => 'partial'])] |
|
70
|
|
|
#[ORM\Column(name: 'sku', type: 'string', length: 32, nullable: true, options: ['default' => 'NULL'])] |
|
71
|
|
|
#[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'])] |
|
72
|
|
|
private $sku = null; |
|
73
|
|
|
|
|
74
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['type' => 'exact'])] |
|
75
|
|
|
#[ORM\Column(name: 'type', type: 'string', length: 0, nullable: false, options: ['default' => "'product'"])] |
|
76
|
|
|
#[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'])] |
|
77
|
|
|
private $type = 'product'; |
|
78
|
|
|
|
|
79
|
|
|
#[ORM\Column(name: 'price', type: 'float', precision: 10, scale: 0, nullable: false)] |
|
80
|
|
|
#[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'])] |
|
81
|
|
|
private $price = 0; |
|
82
|
|
|
|
|
83
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productCondition' => 'exact'])] |
|
84
|
|
|
#[ORM\Column(name: 'product_condition', type: 'string', length: 0, nullable: false, options: ['default' => "'new'"])] |
|
85
|
|
|
#[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'])] |
|
86
|
|
|
private $productCondition = 'new'; |
|
87
|
|
|
|
|
88
|
|
|
#[ORM\Column(name: 'description', type: 'string', length: 0, nullable: false)] |
|
89
|
|
|
#[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'])] |
|
90
|
|
|
private $description = ''; |
|
91
|
|
|
|
|
92
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['featured' => 'exact'])] |
|
93
|
|
|
#[ORM\Column(name: 'featured', type: 'boolean', nullable: false, options: ['default' => '0'])] |
|
94
|
|
|
#[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'])] |
|
95
|
|
|
private $featured = false; |
|
96
|
|
|
|
|
97
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['active' => 'exact'])] |
|
98
|
|
|
#[ORM\Column(name: 'active', type: 'boolean', nullable: false, options: ['default' => '1'])] |
|
99
|
|
|
#[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'])] |
|
100
|
|
|
private $active = true; |
|
101
|
|
|
|
|
102
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['company' => 'exact'])] |
|
103
|
|
|
#[ORM\JoinColumn(name: 'company_id', referencedColumnName: 'id')] |
|
104
|
|
|
#[ORM\ManyToOne(targetEntity: People::class)] |
|
105
|
|
|
#[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'])] |
|
106
|
|
|
private $company; |
|
107
|
|
|
|
|
108
|
|
|
#[ORM\JoinColumn(name: 'product_unity_id', referencedColumnName: 'id')] |
|
109
|
|
|
#[ORM\ManyToOne(targetEntity: ProductUnity::class)] |
|
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
|
|
|
private $productUnit; |
|
112
|
|
|
|
|
113
|
|
|
#[ORM\JoinColumn(name: 'queue_id', referencedColumnName: 'id')] |
|
114
|
|
|
#[ORM\ManyToOne(targetEntity: Queue::class)] |
|
115
|
|
|
#[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'])] |
|
116
|
|
|
private $queue; |
|
117
|
|
|
|
|
118
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['defaultOutInventory' => 'exact'])] |
|
119
|
|
|
#[ORM\JoinColumn(name: 'default_out_inventory_id', referencedColumnName: 'id', nullable: true)] |
|
120
|
|
|
#[ORM\ManyToOne(targetEntity: Inventory::class)] |
|
121
|
|
|
#[Groups(['product:read', 'product:write'])] |
|
122
|
|
|
private $defaultOutInventory; |
|
123
|
|
|
|
|
124
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['defaultInInventory' => 'exact'])] |
|
125
|
|
|
#[ORM\JoinColumn(name: 'default_in_inventory_id', referencedColumnName: 'id', nullable: true)] |
|
126
|
|
|
#[ORM\ManyToOne(targetEntity: Inventory::class)] |
|
127
|
|
|
#[Groups(['product:read', 'product:write'])] |
|
128
|
|
|
private $defaultInInventory; |
|
129
|
|
|
|
|
130
|
|
|
public function __construct() |
|
131
|
|
|
{ |
|
132
|
|
|
$this->productFiles = new ArrayCollection(); |
|
133
|
|
|
$this->productCategory = new ArrayCollection(); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function getId() |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->id; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function setId($id): self |
|
142
|
|
|
{ |
|
143
|
|
|
$this->id = $id; |
|
144
|
|
|
return $this; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
public function getProduct(): string |
|
148
|
|
|
{ |
|
149
|
|
|
return $this->product; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function setProduct(string $product): self |
|
153
|
|
|
{ |
|
154
|
|
|
$this->product = $product; |
|
155
|
|
|
return $this; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
public function getSku(): ?string |
|
159
|
|
|
{ |
|
160
|
|
|
return $this->sku; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
public function setSku(?string $sku): self |
|
164
|
|
|
{ |
|
165
|
|
|
$this->sku = $sku; |
|
166
|
|
|
return $this; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function getType(): string |
|
170
|
|
|
{ |
|
171
|
|
|
return $this->type; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
public function setType(string $type): self |
|
175
|
|
|
{ |
|
176
|
|
|
$this->type = $type; |
|
177
|
|
|
return $this; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
public function getPrice(): float |
|
181
|
|
|
{ |
|
182
|
|
|
return $this->price; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
public function setPrice(float $price): self |
|
186
|
|
|
{ |
|
187
|
|
|
$this->price = $price; |
|
188
|
|
|
return $this; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
public function getProductCondition(): string |
|
192
|
|
|
{ |
|
193
|
|
|
return $this->productCondition; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
public function setProductCondition(string $productCondition): self |
|
197
|
|
|
{ |
|
198
|
|
|
$this->productCondition = $productCondition; |
|
199
|
|
|
return $this; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
public function isActive(): bool |
|
203
|
|
|
{ |
|
204
|
|
|
return $this->active; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
public function setActive(bool $active): self |
|
208
|
|
|
{ |
|
209
|
|
|
$this->active = $active; |
|
210
|
|
|
return $this; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
public function getCompany(): ?People |
|
|
|
|
|
|
214
|
|
|
{ |
|
215
|
|
|
return $this->company; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
public function setCompany(People $company): self |
|
219
|
|
|
{ |
|
220
|
|
|
$this->company = $company; |
|
221
|
|
|
return $this; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
public function getProductUnit(): ProductUnity |
|
225
|
|
|
{ |
|
226
|
|
|
return $this->productUnit; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
public function setProductUnit(ProductUnity $productUnit): self |
|
230
|
|
|
{ |
|
231
|
|
|
$this->productUnit = $productUnit; |
|
232
|
|
|
return $this; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
public function getDescription() |
|
236
|
|
|
{ |
|
237
|
|
|
return $this->description; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
public function setDescription($description): self |
|
241
|
|
|
{ |
|
242
|
|
|
$this->description = $description; |
|
243
|
|
|
return $this; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
public function getQueue() |
|
247
|
|
|
{ |
|
248
|
|
|
return $this->queue; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
public function setQueue($queue): self |
|
252
|
|
|
{ |
|
253
|
|
|
$this->queue = $queue; |
|
254
|
|
|
return $this; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
public function getProductFiles(): Collection |
|
258
|
|
|
{ |
|
259
|
|
|
return $this->productFiles; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
public function getProductCategory(): Collection |
|
263
|
|
|
{ |
|
264
|
|
|
return $this->productCategory; |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
public function getFeatured(): bool |
|
268
|
|
|
{ |
|
269
|
|
|
return $this->featured; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
public function setFeatured(bool $featured): self |
|
273
|
|
|
{ |
|
274
|
|
|
$this->featured = $featured; |
|
275
|
|
|
return $this; |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
public function getDefaultOutInventory(): ?Inventory |
|
279
|
|
|
{ |
|
280
|
|
|
return $this->defaultOutInventory; |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
public function setDefaultOutInventory(Inventory $defaultOutInventory): self |
|
284
|
|
|
{ |
|
285
|
|
|
$this->defaultOutInventory = $defaultOutInventory; |
|
286
|
|
|
return $this; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
public function getDefaultInInventory(): ?Inventory |
|
290
|
|
|
{ |
|
291
|
|
|
return $this->defaultInInventory; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
public function setDefaultInInventory(Inventory $defaultInInventory): self |
|
295
|
|
|
{ |
|
296
|
|
|
$this->defaultInInventory = $defaultInInventory; |
|
297
|
|
|
return $this; |
|
298
|
|
|
} |
|
299
|
|
|
} |
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