1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
6
|
|
|
use Ds\Component\Locale\Model\Type\Localizable; |
|
|
|
|
7
|
|
|
use Ds\Component\Model\Attribute\Accessor; |
|
|
|
|
8
|
|
|
use Ds\Component\Model\Type\Deletable; |
|
|
|
|
9
|
|
|
use Ds\Component\Model\Type\Enableable; |
|
|
|
|
10
|
|
|
use Ds\Component\Model\Type\Identifiable; |
|
|
|
|
11
|
|
|
use Ds\Component\Model\Type\Ownable; |
|
|
|
|
12
|
|
|
use Ds\Component\Model\Type\Sluggable; |
|
|
|
|
13
|
|
|
use Ds\Component\Model\Type\Uuidentifiable; |
|
|
|
|
14
|
|
|
use Ds\Component\Model\Type\Versionable; |
|
|
|
|
15
|
|
|
use Ds\Component\Tenant\Model\Attribute\Accessor as TenantAccessor; |
|
|
|
|
16
|
|
|
use Ds\Component\Tenant\Model\Type\Tenantable; |
|
|
|
|
17
|
|
|
use Ds\Component\Translation\Model\Attribute\Accessor as TranslationAccessor; |
|
|
|
|
18
|
|
|
use Ds\Component\Translation\Model\Type\Translatable; |
|
|
|
|
19
|
|
|
use Knp\DoctrineBehaviors\Model as Behavior; |
|
|
|
|
20
|
|
|
|
21
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
|
|
|
|
22
|
|
|
use ApiPlatform\Core\Annotation\ApiProperty; |
|
|
|
|
23
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
24
|
|
|
use Ds\Component\Locale\Model\Annotation\Locale; |
|
|
|
|
25
|
|
|
use Ds\Component\Translation\Model\Annotation\Translate; |
|
|
|
|
26
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints as ORMAssert; |
|
|
|
|
27
|
|
|
use Symfony\Component\Serializer\Annotation as Serializer; |
|
|
|
|
28
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Class Category |
32
|
|
|
* |
33
|
|
|
* @ApiResource( |
34
|
|
|
* attributes={ |
35
|
|
|
* "normalization_context"={ |
36
|
|
|
* "groups"={"category_output"} |
37
|
|
|
* }, |
38
|
|
|
* "denormalization_context"={ |
39
|
|
|
* "groups"={"category_input"} |
40
|
|
|
* }, |
41
|
|
|
* "filters"={ |
42
|
|
|
* "app.category.search", |
43
|
|
|
* "app.category.search_translation", |
44
|
|
|
* "app.category.date", |
45
|
|
|
* "app.category.boolean", |
46
|
|
|
* "app.category.order", |
47
|
|
|
* "app.category.order_translation" |
48
|
|
|
* } |
49
|
|
|
* } |
50
|
|
|
* ) |
51
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\CategoryRepository") |
52
|
|
|
* @ORM\Table( |
53
|
|
|
* name="app_category", |
54
|
|
|
* uniqueConstraints={ |
55
|
|
|
* @ORM\UniqueConstraint(columns={"slug", "tenant"}) |
56
|
|
|
* } |
57
|
|
|
* ) |
58
|
|
|
* @ORM\Cache(usage="NONSTRICT_READ_WRITE") |
59
|
|
|
* @ORMAssert\UniqueEntity(fields="uuid") |
60
|
|
|
* @ORMAssert\UniqueEntity(fields={"slug", "tenant"}) |
61
|
|
|
*/ |
62
|
|
|
class Category implements Identifiable, Uuidentifiable, Sluggable, Ownable, Translatable, Localizable, Enableable, Deletable, Versionable, Tenantable |
63
|
|
|
{ |
64
|
|
|
use Behavior\Translatable\Translatable; |
|
|
|
|
65
|
|
|
use Behavior\Timestampable\Timestampable; |
|
|
|
|
66
|
|
|
use Behavior\SoftDeletable\SoftDeletable; |
|
|
|
|
67
|
|
|
|
68
|
|
|
use Accessor\Id; |
|
|
|
|
69
|
|
|
use Accessor\Uuid; |
|
|
|
|
70
|
|
|
use Accessor\Owner; |
|
|
|
|
71
|
|
|
use Accessor\OwnerUuid; |
|
|
|
|
72
|
|
|
use Accessor\Slug; |
|
|
|
|
73
|
|
|
use TranslationAccessor\Title; |
|
|
|
|
74
|
|
|
use TranslationAccessor\Description; |
|
|
|
|
75
|
|
|
use TranslationAccessor\Presentation; |
|
|
|
|
76
|
|
|
use TranslationAccessor\Data; |
|
|
|
|
77
|
|
|
use Accessor\Enabled; |
|
|
|
|
78
|
|
|
use Accessor\Deleted; |
|
|
|
|
79
|
|
|
use Accessor\Weight; |
|
|
|
|
80
|
|
|
use Accessor\Version; |
|
|
|
|
81
|
|
|
use TenantAccessor\Tenant; |
|
|
|
|
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var integer |
85
|
|
|
* @ApiProperty(identifier=false, writable=false) |
86
|
|
|
* @Serializer\Groups({"category_output"}) |
87
|
|
|
* @ORM\Id |
88
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
89
|
|
|
* @ORM\Column(name="id", type="integer") |
90
|
|
|
*/ |
91
|
|
|
private $id; |
|
|
|
|
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @var string |
95
|
|
|
* @ApiProperty(identifier=true, writable=false) |
96
|
|
|
* @Serializer\Groups({"category_output"}) |
97
|
|
|
* @ORM\Column(name="uuid", type="guid", unique=true) |
98
|
|
|
* @Assert\Uuid |
99
|
|
|
*/ |
100
|
|
|
private $uuid; |
|
|
|
|
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @var \DateTime |
104
|
|
|
* @ApiProperty |
105
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
106
|
|
|
* @Assert\DateTime |
107
|
|
|
*/ |
108
|
|
|
protected $createdAt; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @var \DateTime |
112
|
|
|
* @ApiProperty(writable=false) |
113
|
|
|
* @Serializer\Groups({"category_output"}) |
114
|
|
|
*/ |
115
|
|
|
protected $updatedAt; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @var \DateTime |
119
|
|
|
* @ApiProperty(writable=false) |
120
|
|
|
* @Serializer\Groups({"category_output"}) |
121
|
|
|
*/ |
122
|
|
|
protected $deletedAt; |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @var string |
126
|
|
|
* @ApiProperty |
127
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
128
|
|
|
* @ORM\Column(name="`owner`", type="string", length=255, nullable=true) |
129
|
|
|
* @Assert\NotBlank |
130
|
|
|
* @Assert\Length(min=1, max=255) |
131
|
|
|
*/ |
132
|
|
|
private $owner; |
|
|
|
|
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @var string |
136
|
|
|
* @ApiProperty |
137
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
138
|
|
|
* @ORM\Column(name="owner_uuid", type="guid", nullable=true) |
139
|
|
|
* @Assert\NotBlank |
140
|
|
|
* @Assert\Uuid |
141
|
|
|
*/ |
142
|
|
|
private $ownerUuid; |
|
|
|
|
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @var string |
146
|
|
|
* @ApiProperty |
147
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
148
|
|
|
* @ORM\Column(name="slug", type="string") |
149
|
|
|
* @Assert\NotBlank |
150
|
|
|
* @Assert\Length(min=1, max=255) |
151
|
|
|
*/ |
152
|
|
|
private $slug; |
|
|
|
|
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @var array |
156
|
|
|
* @ApiProperty |
157
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
158
|
|
|
* @Assert\Type("array") |
159
|
|
|
* @Assert\NotBlank |
160
|
|
|
* @Assert\All({ |
161
|
|
|
* @Assert\NotBlank, |
162
|
|
|
* @Assert\Length(min=1) |
163
|
|
|
* }) |
164
|
|
|
* @Locale |
165
|
|
|
* @Translate |
166
|
|
|
*/ |
167
|
|
|
private $title; |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @var array |
171
|
|
|
* @ApiProperty |
172
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
173
|
|
|
* @Assert\Type("array") |
174
|
|
|
* @Assert\NotBlank |
175
|
|
|
* @Assert\All({ |
176
|
|
|
* @Assert\NotBlank, |
177
|
|
|
* @Assert\Length(min=1) |
178
|
|
|
* }) |
179
|
|
|
* @Locale |
180
|
|
|
* @Translate |
181
|
|
|
*/ |
182
|
|
|
private $description; |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @var array |
186
|
|
|
* @ApiProperty |
187
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
188
|
|
|
* @Assert\Type("array") |
189
|
|
|
* @Assert\NotBlank |
190
|
|
|
* @Assert\All({ |
191
|
|
|
* @Assert\NotBlank, |
192
|
|
|
* @Assert\Length(min=1) |
193
|
|
|
* }) |
194
|
|
|
* @Locale |
195
|
|
|
* @Translate |
196
|
|
|
*/ |
197
|
|
|
private $presentation; |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @var array |
201
|
|
|
* @ApiProperty |
202
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
203
|
|
|
* @Assert\Type("array") |
204
|
|
|
* @Assert\NotBlank |
205
|
|
|
* @Locale |
206
|
|
|
* @Translate |
207
|
|
|
*/ |
208
|
|
|
private $data; |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
212
|
|
|
* @ApiProperty |
213
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
214
|
|
|
* @ORM\ManyToMany(targetEntity="Service", mappedBy="categories") |
215
|
|
|
* @ORM\Cache(usage="NONSTRICT_READ_WRITE") |
216
|
|
|
*/ |
217
|
|
|
private $services; # region accessors |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Add service |
221
|
|
|
* |
222
|
|
|
* @param \App\Entity\Service $service |
223
|
|
|
* @return \App\Entity\Category |
224
|
|
|
*/ |
225
|
|
|
public function addService(Service $service) |
226
|
|
|
{ |
227
|
|
|
if (!$this->services->contains($service)) { |
228
|
|
|
$this->services->add($service); |
229
|
|
|
$service->addCategory($this); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
return $this; |
233
|
|
|
} |
234
|
|
|
/** |
235
|
|
|
* Remove service |
236
|
|
|
* |
237
|
|
|
* @param \App\Entity\Service $service |
238
|
|
|
* @return \App\Entity\Category |
239
|
|
|
*/ |
240
|
|
|
public function removeService(Service $service) |
241
|
|
|
{ |
242
|
|
|
if ($this->services->contains($service)) { |
243
|
|
|
$this->services->removeElement($service); |
244
|
|
|
$service->removeCategory($this); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
return $this; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Get services |
252
|
|
|
* |
253
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection |
254
|
|
|
*/ |
255
|
|
|
public function getServices() |
256
|
|
|
{ |
257
|
|
|
return $this->services; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
# endregion |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @var string |
264
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
265
|
|
|
* @ORM\Column(name="enabled", type="boolean") |
266
|
|
|
* @Assert\Type("boolean") |
267
|
|
|
*/ |
268
|
|
|
private $enabled; |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @var integer |
272
|
|
|
* @ApiProperty |
273
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
274
|
|
|
* @ORM\Column(name="weight", type="smallint") |
275
|
|
|
* @Assert\Length(min=0, max=255) |
276
|
|
|
*/ |
277
|
|
|
private $weight; |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* @var integer |
281
|
|
|
* @ApiProperty |
282
|
|
|
* @Serializer\Groups({"category_output", "category_input"}) |
283
|
|
|
* @ORM\Column(name="version", type="integer") |
284
|
|
|
* @ORM\Version |
285
|
|
|
* @Assert\NotBlank |
286
|
|
|
* @Assert\Type("integer") |
287
|
|
|
*/ |
288
|
|
|
private $version; |
|
|
|
|
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* @var string |
292
|
|
|
* @ApiProperty(writable=false) |
293
|
|
|
* @Serializer\Groups({"category_output"}) |
294
|
|
|
* @ORM\Column(name="tenant", type="guid") |
295
|
|
|
* @Assert\Uuid |
296
|
|
|
*/ |
297
|
|
|
private $tenant; |
|
|
|
|
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* Constructor |
301
|
|
|
*/ |
302
|
|
|
public function __construct() |
303
|
|
|
{ |
304
|
|
|
$this->title = []; |
305
|
|
|
$this->description = []; |
306
|
|
|
$this->presentation = []; |
307
|
|
|
$this->data = []; |
308
|
|
|
$this->services = new ArrayCollection; |
309
|
|
|
$this->enabled = false; |
|
|
|
|
310
|
|
|
$this->weight = 0; |
311
|
|
|
} |
312
|
|
|
} |
313
|
|
|
|
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