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\ProductInventoryRepository; |
18
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
19
|
|
|
|
20
|
|
|
#[ApiResource( |
21
|
|
|
operations: [ |
22
|
|
|
new Get(security: 'is_granted(\'PUBLIC_ACCESS\')'), |
23
|
|
|
new Put(security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['product_inventory:write']]), |
24
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
25
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
26
|
|
|
new GetCollection(security: 'is_granted(\'PUBLIC_ACCESS\')'), |
27
|
|
|
], |
28
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
29
|
|
|
normalizationContext: ['groups' => ['product_inventory:read']], |
30
|
|
|
denormalizationContext: ['groups' => ['product_inventory:write']] |
31
|
|
|
)] |
32
|
|
|
#[ApiFilter(OrderFilter::class, properties: ['id', 'available', 'sales', 'ordered', 'transit'])] |
33
|
|
|
#[ApiFilter(SearchFilter::class, properties: ['id' => 'exact', 'inventory' => 'exact', 'product' => 'exact'])] |
34
|
|
|
#[ORM\Table(name: 'product_inventory')] |
35
|
|
|
#[ORM\Index(name: 'inventory_id', columns: ['inventory_id'])] |
36
|
|
|
#[ORM\Index(name: 'product_id', columns: ['product_id'])] |
37
|
|
|
#[ORM\Entity(repositoryClass: ProductInventoryRepository::class)] |
38
|
|
|
class ProductInventory |
39
|
|
|
{ |
40
|
|
|
#[ORM\Column(name: 'id', type: 'integer', nullable: false)] |
41
|
|
|
#[ORM\Id] |
42
|
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')] |
43
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
44
|
|
|
private $id; |
45
|
|
|
|
46
|
|
|
#[ORM\JoinColumn(name: 'inventory_id', referencedColumnName: 'id', nullable: false)] |
47
|
|
|
#[ORM\ManyToOne(targetEntity: Inventory::class)] |
48
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
49
|
|
|
private $inventory; |
50
|
|
|
|
51
|
|
|
#[ORM\JoinColumn(name: 'product_id', referencedColumnName: 'id', nullable: false)] |
52
|
|
|
#[ORM\ManyToOne(targetEntity: Product::class)] |
53
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
54
|
|
|
private $product; |
55
|
|
|
|
56
|
|
|
#[ORM\Column(name: 'available', type: 'integer', nullable: false, options: ['default' => 0])] |
57
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
58
|
|
|
private $available = 0; |
59
|
|
|
|
60
|
|
|
#[ORM\Column(name: 'sales', type: 'integer', nullable: false, options: ['default' => 0])] |
61
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
62
|
|
|
private $sales = 0; |
63
|
|
|
|
64
|
|
|
#[ORM\Column(name: 'ordered', type: 'integer', nullable: false, options: ['default' => 0])] |
65
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
66
|
|
|
private $ordered = 0; |
67
|
|
|
|
68
|
|
|
#[ORM\Column(name: 'transit', type: 'integer', nullable: false, options: ['default' => 0])] |
69
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
70
|
|
|
private $transit = 0; |
71
|
|
|
|
72
|
|
|
#[ORM\Column(name: 'minimum', type: 'integer', nullable: false, options: ['default' => 0])] |
73
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
74
|
|
|
private $minimum = 0; |
75
|
|
|
|
76
|
|
|
#[ORM\Column(name: 'maximum', type: 'integer', nullable: false, options: ['default' => 0])] |
77
|
|
|
#[Groups(['product_inventory:read', 'product_inventory:write'])] |
78
|
|
|
private $maximum = 0; |
79
|
|
|
|
80
|
|
|
public function getId(): ?int |
81
|
|
|
{ |
82
|
|
|
return $this->id; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function setId(int $id): self |
86
|
|
|
{ |
87
|
|
|
$this->id = $id; |
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function getInventory(): ?Inventory |
92
|
|
|
{ |
93
|
|
|
return $this->inventory; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function setInventory(Inventory $inventory): self |
97
|
|
|
{ |
98
|
|
|
$this->inventory = $inventory; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function getProduct(): ?Product |
103
|
|
|
{ |
104
|
|
|
return $this->product; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function setProduct(Product $product): self |
108
|
|
|
{ |
109
|
|
|
$this->product = $product; |
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function getAvailable(): int |
114
|
|
|
{ |
115
|
|
|
return $this->available; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function setAvailable(int $available): self |
119
|
|
|
{ |
120
|
|
|
$this->available = $available; |
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function getSales(): int |
125
|
|
|
{ |
126
|
|
|
return $this->sales; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function setSales(int $sales): self |
130
|
|
|
{ |
131
|
|
|
$this->sales = $sales; |
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function getOrdered(): int |
136
|
|
|
{ |
137
|
|
|
return $this->ordered; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function setOrdered(int $ordered): self |
141
|
|
|
{ |
142
|
|
|
$this->ordered = $ordered; |
143
|
|
|
return $this; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function getTransit(): int |
147
|
|
|
{ |
148
|
|
|
return $this->transit; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function setTransit(int $transit): self |
152
|
|
|
{ |
153
|
|
|
$this->transit = $transit; |
154
|
|
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function getMinimum(): int |
158
|
|
|
{ |
159
|
|
|
return $this->minimum; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function setMinimum(int $minimum): self |
163
|
|
|
{ |
164
|
|
|
$this->minimum = $minimum; |
165
|
|
|
return $this; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function getMaximum(): int |
169
|
|
|
{ |
170
|
|
|
return $this->maximum; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function setMaximum(int $maximum): self |
174
|
|
|
{ |
175
|
|
|
$this->maximum = $maximum; |
176
|
|
|
return $this; |
177
|
|
|
} |
178
|
|
|
} |
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