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