1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
8
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
15
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
16
|
|
|
use ControleOnline\Listener\LogListener; |
|
|
|
|
17
|
|
|
use ControleOnline\Repository\ProductGroupRepository; |
18
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
19
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
20
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
21
|
|
|
|
22
|
|
|
#[ApiResource( |
23
|
|
|
operations: [ |
24
|
|
|
new Get(security: 'is_granted(\'PUBLIC_ACCESS\')'), |
25
|
|
|
new Put( |
26
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
27
|
|
|
denormalizationContext: ['groups' => ['product_group:write']] |
28
|
|
|
), |
29
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
30
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
31
|
|
|
new GetCollection(security: 'is_granted(\'PUBLIC_ACCESS\')') |
32
|
|
|
], |
33
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
34
|
|
|
normalizationContext: ['groups' => ['product_group:read']], |
35
|
|
|
denormalizationContext: ['groups' => ['product_group:write']] |
36
|
|
|
)] |
37
|
|
|
#[ApiFilter(OrderFilter::class, properties: ['productGroup'])] |
38
|
|
|
#[ORM\Table(name: 'product_group')] |
39
|
|
|
#[ORM\Entity(repositoryClass: ProductGroupRepository::class)] |
40
|
|
|
class ProductGroup |
41
|
|
|
{ |
42
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
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', 'order_product:read'])] |
47
|
|
|
private $id; |
48
|
|
|
|
49
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productGroup' => 'exact'])] |
50
|
|
|
#[ORM\Column(name: 'product_group', type: 'string', length: 255, nullable: false)] |
51
|
|
|
#[Groups(['product_group:read', 'product_group:write', 'order_product:read'])] |
52
|
|
|
private $productGroup; |
53
|
|
|
|
54
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['priceCalculation' => 'exact'])] |
55
|
|
|
#[ORM\Column(name: 'price_calculation', type: 'string', length: 0, nullable: false, options: ['default' => "'sum'"])] |
56
|
|
|
#[Groups(['product_group:read', 'product_group:write', 'order_product:read'])] |
57
|
|
|
private $priceCalculation = 'sum'; |
58
|
|
|
|
59
|
|
|
#[ORM\Column(name: 'required', type: 'boolean', nullable: false)] |
60
|
|
|
#[Groups(['product_group:read', 'product_group:write', 'order_product:read'])] |
61
|
|
|
private $required = false; |
62
|
|
|
|
63
|
|
|
#[ORM\Column(name: 'minimum', type: 'integer', nullable: true, options: ['default' => 'NULL'])] |
64
|
|
|
#[Groups(['product_group:read', 'product_group:write', 'order_product:read'])] |
65
|
|
|
private $minimum = null; |
66
|
|
|
|
67
|
|
|
#[ORM\Column(name: 'maximum', type: 'integer', nullable: true, options: ['default' => 'NULL'])] |
68
|
|
|
#[Groups(['product_group:read', 'product_group:write', 'order_product:read'])] |
69
|
|
|
private $maximum = null; |
70
|
|
|
|
71
|
|
|
#[ORM\Column(name: 'active', type: 'boolean', nullable: false, options: ['default' => '1'])] |
72
|
|
|
#[Groups(['product_group:read', 'product_group:write', 'order_product:read'])] |
73
|
|
|
private $active = true; |
74
|
|
|
|
75
|
|
|
#[ORM\Column(name: 'group_order', type: 'integer', nullable: false)] |
76
|
|
|
#[Groups(['product_group:read', 'product_group:write', 'order_product:read'])] |
77
|
|
|
private $groupOrder = 0; |
78
|
|
|
|
79
|
|
|
#[ORM\OneToMany(targetEntity: ProductGroupProduct::class, mappedBy: 'productGroup', orphanRemoval: true)] |
80
|
|
|
#[Groups(['product_group:write'])] |
81
|
|
|
private $products; |
82
|
|
|
|
83
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['productParent' => 'exact'])] |
84
|
|
|
#[ORM\JoinColumn(nullable: false)] |
85
|
|
|
#[ORM\ManyToOne(targetEntity: Product::class)] |
86
|
|
|
#[Groups(['product_group:read', 'product_group:write'])] |
87
|
|
|
private $productParent; |
88
|
|
|
|
89
|
|
|
public function __construct() |
90
|
|
|
{ |
91
|
|
|
$this->products = new ArrayCollection(); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getId() |
95
|
|
|
{ |
96
|
|
|
return $this->id; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function getProductGroup(): string |
100
|
|
|
{ |
101
|
|
|
return $this->productGroup; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function setProductGroup(string $productGroup): self |
105
|
|
|
{ |
106
|
|
|
$this->productGroup = $productGroup; |
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getPriceCalculation(): string |
111
|
|
|
{ |
112
|
|
|
return $this->priceCalculation; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function setPriceCalculation(string $priceCalculation): self |
116
|
|
|
{ |
117
|
|
|
$this->priceCalculation = $priceCalculation; |
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function isRequired(): bool |
122
|
|
|
{ |
123
|
|
|
return $this->required; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function setRequired(bool $required): self |
127
|
|
|
{ |
128
|
|
|
$this->required = $required; |
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function getMinimum(): ?int |
133
|
|
|
{ |
134
|
|
|
return $this->minimum; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function setMinimum(?int $minimum): self |
138
|
|
|
{ |
139
|
|
|
$this->minimum = $minimum; |
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function getMaximum(): ?int |
144
|
|
|
{ |
145
|
|
|
return $this->maximum; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function setMaximum(?int $maximum): self |
149
|
|
|
{ |
150
|
|
|
$this->maximum = $maximum; |
151
|
|
|
return $this; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function isActive(): bool |
155
|
|
|
{ |
156
|
|
|
return $this->active; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
public function setActive(bool $active): self |
160
|
|
|
{ |
161
|
|
|
$this->active = $active; |
162
|
|
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function getGroupOrder() |
166
|
|
|
{ |
167
|
|
|
return $this->groupOrder; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function setGroupOrder($groupOrder): self |
171
|
|
|
{ |
172
|
|
|
$this->groupOrder = $groupOrder; |
173
|
|
|
return $this; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function getRequired(): ?bool |
177
|
|
|
{ |
178
|
|
|
return $this->required; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function getActive(): ?bool |
182
|
|
|
{ |
183
|
|
|
return $this->active; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
public function getProducts(): Collection |
187
|
|
|
{ |
188
|
|
|
return $this->products; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
public function addProduct(ProductGroupProduct $product): self |
192
|
|
|
{ |
193
|
|
|
if (!$this->products->contains($product)) { |
194
|
|
|
$this->products[] = $product; |
195
|
|
|
$product->setProductGroup($this); |
196
|
|
|
} |
197
|
|
|
return $this; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
public function removeProduct(ProductGroupProduct $product): self |
201
|
|
|
{ |
202
|
|
|
if ($this->products->removeElement($product)) { |
203
|
|
|
if ($product->getProductGroup() === $this) { |
204
|
|
|
$product->setProductGroup(null); |
205
|
|
|
} |
206
|
|
|
} |
207
|
|
|
return $this; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
public function getProductParent() |
211
|
|
|
{ |
212
|
|
|
return $this->productParent; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
public function setProductParent($productParent): self |
216
|
|
|
{ |
217
|
|
|
$this->productParent = $productParent; |
218
|
|
|
return $this; |
219
|
|
|
} |
220
|
|
|
} |
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