1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\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 ControleOnline\Entity\SalesOrderInvoice; |
|
|
|
|
14
|
|
|
use stdClass; |
15
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\DateFilter; |
|
|
|
|
16
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
17
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
18
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
19
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
20
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
21
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
|
|
|
|
22
|
|
|
|
23
|
|
|
#[ApiResource( |
24
|
|
|
operations: [ |
25
|
|
|
new Get( |
26
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
27
|
|
|
), |
28
|
|
|
new GetCollection( |
29
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')', |
30
|
|
|
), |
31
|
|
|
new Post( |
32
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')', |
33
|
|
|
validationContext: ['groups' => ['order_product_write']], |
34
|
|
|
denormalizationContext: ['groups' => ['order_product_write']] |
35
|
|
|
), |
36
|
|
|
new Put( |
37
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
38
|
|
|
validationContext: ['groups' => ['order_product_write']], |
39
|
|
|
denormalizationContext: ['groups' => ['order_product_write']] |
40
|
|
|
), |
41
|
|
|
], |
42
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
43
|
|
|
normalizationContext: ['groups' => ['order_product_read']], |
44
|
|
|
denormalizationContext: ['groups' => ['order_product_write']] |
45
|
|
|
)] |
46
|
|
|
#[ApiFilter(filterClass: OrderFilter::class, properties: ['alterDate' => 'DESC'])] |
47
|
|
|
|
48
|
|
|
class OrderProduct |
49
|
|
|
{ |
50
|
|
|
/** |
51
|
|
|
* @ORM\Id |
52
|
|
|
* @ORM\GeneratedValue |
53
|
|
|
* @ORM\Column(type="integer") |
54
|
|
|
* @Groups({"order_read","order_product_write","order_product_read"}) |
55
|
|
|
*/ |
56
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
57
|
|
|
private $id; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Order") |
61
|
|
|
* @ORM\JoinColumn(nullable=false) |
62
|
|
|
* @Groups({"order_read","order_product_write","order_product_read"}) |
63
|
|
|
*/ |
64
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
65
|
|
|
private $order; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Product") |
69
|
|
|
* @ORM\JoinColumn(nullable=false) |
70
|
|
|
* @Groups({"order_read","order_product_write","order_product_read"}) |
71
|
|
|
*/ |
72
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
73
|
|
|
private $product; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @ORM\Column(type="float") |
77
|
|
|
* @Groups({"order_read","order_product_write","order_product_read"}) |
78
|
|
|
*/ |
79
|
|
|
private $quantity; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @ORM\Column(type="float") |
83
|
|
|
* @Groups({"order_read","order_product_write","order_product_read"}) |
84
|
|
|
*/ |
85
|
|
|
private $price; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @ORM\Column(type="float") |
89
|
|
|
* @Groups({"order_read","order_product_write","order_product_read"}) |
90
|
|
|
*/ |
91
|
|
|
private $total; |
92
|
|
|
|
93
|
|
|
// Getters and setters |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get the value of id |
97
|
|
|
*/ |
98
|
|
|
public function getId() |
99
|
|
|
{ |
100
|
|
|
return $this->id; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Set the value of id |
105
|
|
|
*/ |
106
|
|
|
public function setId($id): self |
107
|
|
|
{ |
108
|
|
|
$this->id = $id; |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get the value of order |
115
|
|
|
*/ |
116
|
|
|
public function getOrder() |
117
|
|
|
{ |
118
|
|
|
return $this->order; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Set the value of order |
123
|
|
|
*/ |
124
|
|
|
public function setOrder($order): self |
125
|
|
|
{ |
126
|
|
|
$this->order = $order; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Get the value of product |
133
|
|
|
*/ |
134
|
|
|
public function getProduct() |
135
|
|
|
{ |
136
|
|
|
return $this->product; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set the value of product |
141
|
|
|
*/ |
142
|
|
|
public function setProduct($product): self |
143
|
|
|
{ |
144
|
|
|
$this->product = $product; |
145
|
|
|
|
146
|
|
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Get the value of quantity |
151
|
|
|
*/ |
152
|
|
|
public function getQuantity() |
153
|
|
|
{ |
154
|
|
|
return $this->quantity; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Set the value of quantity |
159
|
|
|
*/ |
160
|
|
|
public function setQuantity($quantity): self |
161
|
|
|
{ |
162
|
|
|
$this->quantity = $quantity; |
163
|
|
|
|
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Get the value of price |
169
|
|
|
*/ |
170
|
|
|
public function getPrice() |
171
|
|
|
{ |
172
|
|
|
return $this->price; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Set the value of price |
177
|
|
|
*/ |
178
|
|
|
public function setPrice($price): self |
179
|
|
|
{ |
180
|
|
|
$this->price = $price; |
181
|
|
|
|
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Get the value of total |
187
|
|
|
*/ |
188
|
|
|
public function getTotal() |
189
|
|
|
{ |
190
|
|
|
return $this->total; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Set the value of total |
195
|
|
|
*/ |
196
|
|
|
public function setTotal($total): self |
197
|
|
|
{ |
198
|
|
|
$this->total = $total; |
199
|
|
|
|
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
} |
203
|
|
|
|
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