1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
6
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
|
|
|
|
12
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
13
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter; |
|
|
|
|
14
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
15
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
16
|
|
|
use ControleOnline\Filter\CustomOrFilter; |
17
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
18
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
|
19
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
|
|
|
20
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class}) |
24
|
|
|
* @ORM\Table (name="category") |
25
|
|
|
* @ORM\Entity (repositoryClass="ControleOnline\Repository\CategoryRepository") |
26
|
|
|
*/ |
27
|
|
|
#[ApiResource( |
28
|
|
|
operations: [ |
29
|
|
|
new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'), |
30
|
|
|
new Put( |
31
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
32
|
|
|
denormalizationContext: ['groups' => ['category:write']] |
33
|
|
|
), |
34
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
35
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
36
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')') |
37
|
|
|
], |
38
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
39
|
|
|
normalizationContext: ['groups' => ['category:read']], |
40
|
|
|
denormalizationContext: ['groups' => ['category:write']] |
41
|
|
|
)] |
42
|
|
|
#[ApiFilter(filterClass: ExistsFilter::class, properties: ['parent'])] |
43
|
|
|
#[ApiFilter(filterClass: OrderFilter::class, properties: ['name' => 'ASC'])] |
44
|
|
|
#[ApiFilter(CustomOrFilter::class, properties: ['name', 'id', 'icon', 'color'])] |
45
|
|
|
|
46
|
|
|
class Category |
47
|
|
|
{ |
48
|
|
|
/** |
49
|
|
|
* @var integer |
50
|
|
|
* |
51
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
52
|
|
|
* @ORM\Id |
53
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
54
|
|
|
* @Groups({"product_category:read","logistic:read","invoice_details:read","category:read","task:read", "company_expense:read", |
55
|
|
|
* "model:read","model_detail:read", |
56
|
|
|
* "menu:read","invoice:read"}) |
57
|
|
|
*/ |
58
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
59
|
|
|
|
60
|
|
|
private $id; |
61
|
|
|
/** |
62
|
|
|
* @var string |
63
|
|
|
* |
64
|
|
|
* @ORM\Column(name="name", type="string", length=100, nullable=false) |
65
|
|
|
* @Groups({"product_category:read","menu:read","logistic:read","invoice_details:read","category:read","task:read", "category:write", |
66
|
|
|
* "model:read","model_detail:read", |
67
|
|
|
* "company_expense:read", "queue:read","invoice:read"}) |
68
|
|
|
* @Assert\NotBlank |
69
|
|
|
* @Assert\Type(type={"string"}) |
70
|
|
|
*/ |
71
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial'])] |
72
|
|
|
|
73
|
|
|
private $name; |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @ORM\OneToMany(targetEntity="CategoryFile", mappedBy="category") |
78
|
|
|
* @Groups({"category:read"}) |
79
|
|
|
*/ |
80
|
|
|
#[ApiFilter(filterClass: ExistsFilter::class, properties: ['categoryFiles'])] |
81
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['categoryFiles.file.fileType' => 'exact'])] |
82
|
|
|
|
83
|
|
|
private $categoryFiles; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var string |
87
|
|
|
* |
88
|
|
|
* @ORM\Column(name="context", type="string", length=100, nullable=false) |
89
|
|
|
* @Groups({"product_category:read","logistic:read","invoice_details:read","category:read","task:read", "category:write","menu:read", |
90
|
|
|
* "model:read","model_detail:read", |
91
|
|
|
* "queue:read","invoice:read"}) |
92
|
|
|
* @Assert\NotBlank |
93
|
|
|
* @Assert\Type(type={"string"}) |
94
|
|
|
*/ |
95
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['context' => 'exact'])] |
96
|
|
|
|
97
|
|
|
private $context; |
98
|
|
|
/** |
99
|
|
|
* @var \ControleOnline\Entity\Category |
100
|
|
|
* |
101
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Category") |
102
|
|
|
* @ORM\JoinColumns({ |
103
|
|
|
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true) |
104
|
|
|
* }) |
105
|
|
|
* @Groups({"logistic:read","invoice_details:read","category:read","task:read", "category:write", |
106
|
|
|
* "model:read","model_detail:read", |
107
|
|
|
* "category:write","menu:read","queue:read"}) |
108
|
|
|
*/ |
109
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['parent' => 'exact'])] |
110
|
|
|
|
111
|
|
|
private $parent; |
112
|
|
|
/** |
113
|
|
|
* @var \ControleOnline\Entity\People |
|
|
|
|
114
|
|
|
* |
115
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
116
|
|
|
* @ORM\JoinColumns({ |
117
|
|
|
* @ORM\JoinColumn(name="company_id", referencedColumnName="id") |
118
|
|
|
* }) |
119
|
|
|
* @Groups({"product_category:read","logistic:read","invoice_details:read","category:read", "category:write","menu:read", |
120
|
|
|
* "model:read","model_detail:read", |
121
|
|
|
* "queue:read","invoice:read"}) |
122
|
|
|
* @Assert\NotBlank |
123
|
|
|
*/ |
124
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['company' => 'exact'])] |
125
|
|
|
|
126
|
|
|
private $company; |
127
|
|
|
/** |
128
|
|
|
* @var string |
129
|
|
|
* |
130
|
|
|
* @ORM\Column(name="icon", type="string", length=50, nullable=false) |
131
|
|
|
* @Groups({"product_category:read","logistic:read","invoice_details:read","category:read","task:read", "category:write", "company_expense:read", |
132
|
|
|
* "model:read","model_detail:read", |
133
|
|
|
* "category:write","menu:read","queue:read","invoice:read"}) |
134
|
|
|
* @Assert\Type(type={"string"}) |
135
|
|
|
*/ |
136
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['icon' => 'exact'])] |
137
|
|
|
|
138
|
|
|
private $icon; |
139
|
|
|
/** |
140
|
|
|
* @var string |
141
|
|
|
* |
142
|
|
|
* @ORM\Column(name="color", type="string", length=50, nullable=false) |
143
|
|
|
* @Groups({"product_category:read","logistic:read","invoice_details:read","category:read","task:read", "category:write", "company_expense:read", |
144
|
|
|
* "model:read","model_detail:read", |
145
|
|
|
* "category:write","menu:read","queue:read","invoice:read"}) |
146
|
|
|
* @Assert\Type(type={"string"}) |
147
|
|
|
*/ |
148
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['color' => 'exact'])] |
149
|
|
|
|
150
|
|
|
private $color; |
151
|
|
|
|
152
|
|
|
|
153
|
|
|
public function __construct() |
154
|
|
|
{ |
155
|
|
|
$this->categoryFiles = new \Doctrine\Common\Collections\ArrayCollection(); |
|
|
|
|
156
|
|
|
} |
157
|
|
|
/** |
158
|
|
|
* Get id |
159
|
|
|
* |
160
|
|
|
* @return integer |
161
|
|
|
*/ |
162
|
|
|
public function getId() |
163
|
|
|
{ |
164
|
|
|
return $this->id; |
165
|
|
|
} |
166
|
|
|
public function setName($name) |
167
|
|
|
{ |
168
|
|
|
$this->name = $name; |
169
|
|
|
return $this; |
170
|
|
|
} |
171
|
|
|
public function getName() |
172
|
|
|
{ |
173
|
|
|
return $this->name; |
174
|
|
|
} |
175
|
|
|
public function setContext($context) |
176
|
|
|
{ |
177
|
|
|
$this->context = $context; |
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
|
|
public function getContext() |
181
|
|
|
{ |
182
|
|
|
return $this->context; |
183
|
|
|
} |
184
|
|
|
public function setParent(Category $category = null) |
185
|
|
|
{ |
186
|
|
|
$this->parent = $category; |
187
|
|
|
return $this; |
188
|
|
|
} |
189
|
|
|
public function getParent(): ?Category |
190
|
|
|
{ |
191
|
|
|
return $this->parent; |
192
|
|
|
} |
193
|
|
|
public function setCompany(People $company) |
194
|
|
|
{ |
195
|
|
|
$this->company = $company; |
196
|
|
|
return $this; |
197
|
|
|
} |
198
|
|
|
public function getCompany() |
199
|
|
|
{ |
200
|
|
|
return $this->company; |
201
|
|
|
} |
202
|
|
|
/** |
203
|
|
|
* Get the value of icon |
204
|
|
|
*/ |
205
|
|
|
public function getIcon() |
206
|
|
|
{ |
207
|
|
|
return $this->icon; |
208
|
|
|
} |
209
|
|
|
/** |
210
|
|
|
* Set the value of icon |
211
|
|
|
*/ |
212
|
|
|
public function setIcon($icon): self |
213
|
|
|
{ |
214
|
|
|
$this->icon = $icon; |
215
|
|
|
return $this; |
216
|
|
|
} |
217
|
|
|
/** |
218
|
|
|
* Get the value of color |
219
|
|
|
*/ |
220
|
|
|
public function getColor() |
221
|
|
|
{ |
222
|
|
|
return $this->color; |
223
|
|
|
} |
224
|
|
|
/** |
225
|
|
|
* Set the value of color |
226
|
|
|
*/ |
227
|
|
|
public function setColor($color): self |
228
|
|
|
{ |
229
|
|
|
$this->color = $color; |
230
|
|
|
return $this; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @return Collection|CategoryFile[] |
235
|
|
|
*/ |
236
|
|
|
public function getCategoryFiles(): Collection |
237
|
|
|
{ |
238
|
|
|
return $this->categoryFiles; |
239
|
|
|
} |
240
|
|
|
} |
241
|
|
|
|
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