1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
6
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
13
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
15
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
16
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
17
|
|
|
use Doctrine\ORM\Mapping\OneToMany; |
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* ProductGroup |
21
|
|
|
* |
22
|
|
|
* @ORM\Table(name="product_group") |
23
|
|
|
* @ORM\Entity(repositoryClass="ControleOnline\Repository\ProductGroupRepository") |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
#[ApiResource( |
27
|
|
|
operations: [ |
28
|
|
|
new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'), |
29
|
|
|
new Put(security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['product_group_write']]), |
30
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
31
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
32
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')') |
33
|
|
|
], |
34
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
35
|
|
|
normalizationContext: ['groups' => ['product_group_read']], |
36
|
|
|
denormalizationContext: ['groups' => ['product_group_write']] |
37
|
|
|
)] |
38
|
|
|
class ProductGroup |
39
|
|
|
{ |
40
|
|
|
/** |
41
|
|
|
* @var int |
42
|
|
|
* |
43
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
44
|
|
|
* @ORM\Id |
45
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
46
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
47
|
|
|
*/ |
48
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
49
|
|
|
private $id; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string |
53
|
|
|
* |
54
|
|
|
* @ORM\Column(name="product_group", type="string", length=255, nullable=false) |
55
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
56
|
|
|
*/ |
57
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productGroup' => 'exact'])] |
58
|
|
|
|
59
|
|
|
private $productGroup; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var string |
63
|
|
|
* |
64
|
|
|
* @ORM\Column(name="price_calculation", type="string", length=0, nullable=false, options={"default"="'sum'"}) |
65
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
66
|
|
|
*/ |
67
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['priceCalculation' => 'exact'])] |
68
|
|
|
|
69
|
|
|
private $priceCalculation = 'sum'; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var bool |
73
|
|
|
* |
74
|
|
|
* @ORM\Column(name="required", type="boolean", nullable=false) |
75
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
76
|
|
|
*/ |
77
|
|
|
private $required = 0; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var int|null |
81
|
|
|
* |
82
|
|
|
* @ORM\Column(name="minimum", type="integer", nullable=true, options={"default"="NULL"}) |
83
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
84
|
|
|
*/ |
85
|
|
|
private $minimum = NULL; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @var int|null |
89
|
|
|
* |
90
|
|
|
* @ORM\Column(name="maximum", type="integer", nullable=true, options={"default"="NULL"}) |
91
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
92
|
|
|
*/ |
93
|
|
|
private $maximum = NULL; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @var bool |
97
|
|
|
* |
98
|
|
|
* @ORM\Column(name="active", type="boolean", nullable=false, options={"default"="1"}) |
99
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
100
|
|
|
*/ |
101
|
|
|
private $active = true; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @var int |
105
|
|
|
* |
106
|
|
|
* @ORM\Column(name="group_order", type="integer", nullable=false) |
107
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
108
|
|
|
*/ |
109
|
|
|
|
110
|
|
|
private $groupOrder; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @var Collection|ProductGroupProduct[] |
114
|
|
|
* |
115
|
|
|
* @ORM\OneToMany(targetEntity="ProductGroupProduct", mappedBy="productGroup", orphanRemoval=true) |
116
|
|
|
* @Groups({"product_group_read","product_group_write"}) |
117
|
|
|
*/ |
118
|
|
|
private $products; |
119
|
|
|
|
120
|
|
|
public function __construct() |
121
|
|
|
{ |
122
|
|
|
$this->products = new ArrayCollection(); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Get the value of id |
127
|
|
|
*/ |
128
|
|
|
public function getId(): int |
129
|
|
|
{ |
130
|
|
|
return $this->id; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Get the value of productGroup |
135
|
|
|
*/ |
136
|
|
|
public function getProductGroup(): string |
137
|
|
|
{ |
138
|
|
|
return $this->productGroup; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Set the value of productGroup |
143
|
|
|
*/ |
144
|
|
|
public function setProductGroup(string $productGroup): self |
145
|
|
|
{ |
146
|
|
|
$this->productGroup = $productGroup; |
147
|
|
|
|
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Get the value of priceCalculation |
153
|
|
|
*/ |
154
|
|
|
public function getPriceCalculation(): string |
155
|
|
|
{ |
156
|
|
|
return $this->priceCalculation; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Set the value of priceCalculation |
161
|
|
|
*/ |
162
|
|
|
public function setPriceCalculation(string $priceCalculation): self |
163
|
|
|
{ |
164
|
|
|
$this->priceCalculation = $priceCalculation; |
165
|
|
|
|
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Get the value of required |
171
|
|
|
*/ |
172
|
|
|
public function isRequired(): bool |
173
|
|
|
{ |
174
|
|
|
return $this->required; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Set the value of required |
179
|
|
|
*/ |
180
|
|
|
public function setRequired(bool $required): self |
181
|
|
|
{ |
182
|
|
|
$this->required = $required; |
183
|
|
|
|
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Get the value of minimum |
189
|
|
|
*/ |
190
|
|
|
public function getMinimum(): ?int |
191
|
|
|
{ |
192
|
|
|
return $this->minimum; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Set the value of minimum |
197
|
|
|
*/ |
198
|
|
|
public function setMinimum(?int $minimum): self |
199
|
|
|
{ |
200
|
|
|
$this->minimum = $minimum; |
201
|
|
|
|
202
|
|
|
return $this; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Get the value of maximum |
207
|
|
|
*/ |
208
|
|
|
public function getMaximum(): ?int |
209
|
|
|
{ |
210
|
|
|
return $this->maximum; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Set the value of maximum |
215
|
|
|
*/ |
216
|
|
|
public function setMaximum(?int $maximum): self |
217
|
|
|
{ |
218
|
|
|
$this->maximum = $maximum; |
219
|
|
|
|
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Get the value of active |
225
|
|
|
*/ |
226
|
|
|
public function isActive(): bool |
227
|
|
|
{ |
228
|
|
|
return $this->active; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Set the value of active |
233
|
|
|
*/ |
234
|
|
|
public function setActive(bool $active): self |
235
|
|
|
{ |
236
|
|
|
$this->active = $active; |
237
|
|
|
|
238
|
|
|
return $this; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Get the value of groupOrder |
243
|
|
|
*/ |
244
|
|
|
public function getGroupOrder(): int |
245
|
|
|
{ |
246
|
|
|
return $this->groupOrder; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* Set the value of groupOrder |
251
|
|
|
*/ |
252
|
|
|
public function setGroupOrder(int $groupOrder): self |
253
|
|
|
{ |
254
|
|
|
$this->groupOrder = $groupOrder; |
255
|
|
|
|
256
|
|
|
return $this; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
public function getRequired(): ?bool |
260
|
|
|
{ |
261
|
|
|
return $this->required; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
public function getActive(): ?bool |
265
|
|
|
{ |
266
|
|
|
return $this->active; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* @return Collection|ProductGroupProduct[] |
271
|
|
|
*/ |
272
|
|
|
public function getProducts(): Collection |
273
|
|
|
{ |
274
|
|
|
return $this->products; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function addProduct(ProductGroupProduct $product): self |
278
|
|
|
{ |
279
|
|
|
if (!$this->products->contains($product)) { |
280
|
|
|
$this->products[] = $product; |
281
|
|
|
$product->setProductGroup($this); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
return $this; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
public function removeProduct(ProductGroupProduct $product): self |
288
|
|
|
{ |
289
|
|
|
if ($this->products->removeElement($product)) { |
290
|
|
|
// set the owning side to null (unless already changed) |
291
|
|
|
if ($product->getProductGroup() === $this) { |
292
|
|
|
$product->setProductGroup(null); |
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
return $this; |
297
|
|
|
} |
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