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