1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
15
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
16
|
|
|
use ControleOnline\Entity\Order; |
17
|
|
|
use ControleOnline\Entity\Product; |
|
|
|
|
18
|
|
|
use ControleOnline\Entity\Inventory; |
|
|
|
|
19
|
|
|
use ControleOnline\Entity\ProductGroup; |
|
|
|
|
20
|
|
|
use ControleOnline\Entity\OrderProductQueue; |
|
|
|
|
21
|
|
|
use ControleOnline\Repository\OrderProductRepository; |
22
|
|
|
use ControleOnline\Listener\LogListener; |
23
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
24
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
25
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter; |
|
|
|
|
26
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\NumericFilter; |
|
|
|
|
27
|
|
|
|
28
|
|
|
#[ORM\Table(name: 'order_product')] |
29
|
|
|
#[ORM\EntityListeners([LogListener::class])] |
30
|
|
|
#[ORM\Entity(repositoryClass: OrderProductRepository::class)] |
31
|
|
|
#[ApiResource( |
32
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
33
|
|
|
normalizationContext: ['groups' => ['order_product:read']], |
34
|
|
|
denormalizationContext: ['groups' => ['order_product:write']], |
35
|
|
|
operations: [ |
36
|
|
|
new GetCollection(security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')"), |
37
|
|
|
new Get(security: "is_granted('ROLE_CLIENT')"), |
38
|
|
|
new Post(security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')"), |
39
|
|
|
new Put(security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')"), |
40
|
|
|
new Delete(security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") |
41
|
|
|
] |
42
|
|
|
)] |
43
|
|
|
#[ApiFilter(OrderFilter::class, properties: ['alterDate' => 'DESC', 'id' => 'ASC', 'product.product' => 'ASC'])] |
44
|
|
|
#[ApiFilter(NumericFilter::class, properties: ['order.id'])] |
45
|
|
|
#[ApiFilter(SearchFilter::class, properties: [ |
46
|
|
|
'id' => 'exact', |
47
|
|
|
'order' => 'exact', |
48
|
|
|
'product' => 'exact', |
49
|
|
|
'product.type' => 'exact', |
50
|
|
|
'inInventory' => 'exact', |
51
|
|
|
'outInventory' => 'exact', |
52
|
|
|
'parentProduct' => 'exact', |
53
|
|
|
'parentProduct.type' => 'exact', |
54
|
|
|
'orderProduct' => 'exact', |
55
|
|
|
'orderProduct.type' => 'exact', |
56
|
|
|
'productGroup' => 'exact', |
57
|
|
|
'productGroup.type' => 'exact' |
58
|
|
|
])] |
59
|
|
|
#[ApiFilter(ExistsFilter::class, properties: [ |
60
|
|
|
'inInventory', |
61
|
|
|
'outInventory', |
62
|
|
|
'parentProduct', |
63
|
|
|
'orderProduct', |
64
|
|
|
'productGroup' |
65
|
|
|
])] |
66
|
|
|
class OrderProduct |
67
|
|
|
{ |
68
|
|
|
#[ORM\Id] |
69
|
|
|
#[ORM\GeneratedValue] |
70
|
|
|
#[ORM\Column(type: 'integer')] |
71
|
|
|
#[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write', 'order_product:write', 'order_product:read'])] |
72
|
|
|
private $id; |
73
|
|
|
|
74
|
|
|
#[ORM\ManyToOne(targetEntity: Order::class)] |
75
|
|
|
#[ORM\JoinColumn(nullable: false)] |
76
|
|
|
#[Groups(['order_product_queue:read', 'order_product:write', 'order_product:read'])] |
77
|
|
|
private $order; |
78
|
|
|
|
79
|
|
|
#[ORM\ManyToOne(targetEntity: Product::class)] |
80
|
|
|
#[ORM\JoinColumn(nullable: false)] |
81
|
|
|
#[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write', 'order_product:write', 'order_product:read'])] |
82
|
|
|
private $product; |
83
|
|
|
|
84
|
|
|
#[ORM\ManyToOne(targetEntity: Inventory::class)] |
85
|
|
|
#[ORM\JoinColumn(name: 'in_inventory_id', referencedColumnName: 'id', nullable: true)] |
86
|
|
|
#[Groups(['order_product:write', 'order_product:read'])] |
87
|
|
|
private $inInventory; |
88
|
|
|
|
89
|
|
|
#[ORM\ManyToOne(targetEntity: Inventory::class)] |
90
|
|
|
#[ORM\JoinColumn(name: 'out_inventory_id', referencedColumnName: 'id', nullable: true)] |
91
|
|
|
#[Groups(['order_product:write', 'order_product:read'])] |
92
|
|
|
private $outInventory; |
93
|
|
|
|
94
|
|
|
#[ORM\ManyToOne(targetEntity: Product::class)] |
95
|
|
|
#[ORM\JoinColumn(name: 'parent_product_id', referencedColumnName: 'id', nullable: true)] |
96
|
|
|
#[Groups(['order_product:write', 'order_product:read'])] |
97
|
|
|
private $parentProduct; |
98
|
|
|
|
99
|
|
|
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'orderProductComponents')] |
100
|
|
|
#[ORM\JoinColumn(name: 'order_product_id', nullable: true)] |
101
|
|
|
#[Groups(['order_product:write', 'order_product:read'])] |
102
|
|
|
private $orderProduct; |
103
|
|
|
|
104
|
|
|
#[ORM\ManyToOne(targetEntity: ProductGroup::class)] |
105
|
|
|
#[ORM\JoinColumn(nullable: true)] |
106
|
|
|
#[Groups(['order_product:write', 'order_product:read'])] |
107
|
|
|
private $productGroup; |
108
|
|
|
|
109
|
|
|
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'orderProduct')] |
110
|
|
|
#[Groups(['order_product:write', 'order_product:read'])] |
111
|
|
|
private $orderProductComponents; |
112
|
|
|
|
113
|
|
|
#[ORM\OneToMany(targetEntity: OrderProductQueue::class, mappedBy: 'order_product')] |
114
|
|
|
#[Groups(['order_product:read'])] |
115
|
|
|
private $orderProductQueues; |
116
|
|
|
|
117
|
|
|
#[ORM\Column(type: 'float')] |
118
|
|
|
#[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write', 'order_product:write', 'order_product:read'])] |
119
|
|
|
private $quantity = 1; |
120
|
|
|
|
121
|
|
|
#[ORM\Column(type: 'float')] |
122
|
|
|
#[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write', 'order_product:write', 'order_product:read'])] |
123
|
|
|
private $price = 0; |
124
|
|
|
|
125
|
|
|
#[ORM\Column(type: 'float')] |
126
|
|
|
#[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write', 'order_product:write', 'order_product:read'])] |
127
|
|
|
private $total = 0; |
128
|
|
|
|
129
|
|
|
public function __construct() |
130
|
|
|
{ |
131
|
|
|
$this->orderProductQueues = new ArrayCollection(); |
132
|
|
|
$this->orderProductComponents = new ArrayCollection(); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function getId() |
136
|
|
|
{ |
137
|
|
|
return $this->id; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function setId($id): self |
141
|
|
|
{ |
142
|
|
|
$this->id = $id; |
143
|
|
|
return $this; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function getOrder() |
147
|
|
|
{ |
148
|
|
|
return $this->order; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function setOrder($order): self |
152
|
|
|
{ |
153
|
|
|
$this->order = $order; |
154
|
|
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function getProduct() |
158
|
|
|
{ |
159
|
|
|
return $this->product; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function setProduct($product): self |
163
|
|
|
{ |
164
|
|
|
$this->product = $product; |
165
|
|
|
return $this; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function getInInventory() |
169
|
|
|
{ |
170
|
|
|
return $this->inInventory; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function setInInventory($inInventory): self |
174
|
|
|
{ |
175
|
|
|
$this->inInventory = $inInventory; |
176
|
|
|
return $this; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
public function getOutInventory() |
180
|
|
|
{ |
181
|
|
|
return $this->outInventory; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public function setOutInventory($outInventory): self |
185
|
|
|
{ |
186
|
|
|
$this->outInventory = $outInventory; |
187
|
|
|
return $this; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
public function getParentProduct() |
191
|
|
|
{ |
192
|
|
|
return $this->parentProduct; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function setParentProduct($parentProduct): self |
196
|
|
|
{ |
197
|
|
|
$this->parentProduct = $parentProduct; |
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
public function getOrderProduct() |
202
|
|
|
{ |
203
|
|
|
return $this->orderProduct; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
public function setOrderProduct(?OrderProduct $orderProduct): self |
207
|
|
|
{ |
208
|
|
|
$this->orderProduct = $orderProduct; |
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
public function getProductGroup() |
213
|
|
|
{ |
214
|
|
|
return $this->productGroup; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function setProductGroup($productGroup): self |
218
|
|
|
{ |
219
|
|
|
$this->productGroup = $productGroup; |
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
public function getOrderProductQueues() |
224
|
|
|
{ |
225
|
|
|
return $this->orderProductQueues; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function addOrderProductQueue(OrderProductQueue $orderProductQueue): self |
229
|
|
|
{ |
230
|
|
|
if (!$this->orderProductQueues->contains($orderProductQueue)) { |
231
|
|
|
$this->orderProductQueues[] = $orderProductQueue; |
232
|
|
|
$orderProductQueue->setOrderProduct($this); |
233
|
|
|
} |
234
|
|
|
return $this; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
public function removeOrderProductQueue(OrderProductQueue $orderProductQueue): self |
238
|
|
|
{ |
239
|
|
|
if ($this->orderProductQueues->removeElement($orderProductQueue)) { |
240
|
|
|
if ($orderProductQueue->getOrderProduct() === $this) { |
241
|
|
|
$orderProductQueue->setOrderProduct(null); |
242
|
|
|
} |
243
|
|
|
} |
244
|
|
|
return $this; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
public function getOrderProductComponents() |
248
|
|
|
{ |
249
|
|
|
return $this->orderProductComponents; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
public function addOrderProductComponent(OrderProduct $orderProductComponent): self |
253
|
|
|
{ |
254
|
|
|
if (!$this->orderProductComponents->contains($orderProductComponent)) { |
255
|
|
|
$this->orderProductComponents[] = $orderProductComponent; |
256
|
|
|
$orderProductComponent->setOrderProduct($this); |
257
|
|
|
} |
258
|
|
|
return $this; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
public function removeOrderProductComponent(OrderProduct $orderProductComponent): self |
262
|
|
|
{ |
263
|
|
|
if ($this->orderProductComponents->removeElement($orderProductComponent)) { |
264
|
|
|
if ($orderProductComponent->getOrderProduct() === $this) { |
265
|
|
|
$orderProductComponent->setOrderProduct(null); |
266
|
|
|
} |
267
|
|
|
} |
268
|
|
|
return $this; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
public function getQuantity() |
272
|
|
|
{ |
273
|
|
|
return $this->quantity; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
public function setQuantity($quantity): self |
277
|
|
|
{ |
278
|
|
|
$this->quantity = $quantity; |
279
|
|
|
return $this; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
public function getPrice() |
283
|
|
|
{ |
284
|
|
|
return $this->price; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
public function setPrice($price): self |
288
|
|
|
{ |
289
|
|
|
$this->price = $price; |
290
|
|
|
return $this; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
public function getTotal() |
294
|
|
|
{ |
295
|
|
|
return $this->total; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
public function setTotal($total): self |
299
|
|
|
{ |
300
|
|
|
$this->total = $total; |
301
|
|
|
return $this; |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
|
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