1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use AppBundle\Entity\Translations\EmployeeTranslation; |
6
|
|
|
use Application\Sonata\MediaBundle\Entity\GalleryHasMedia; |
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
9
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
10
|
|
|
use Gedmo\Blameable\Traits\BlameableEntity; |
11
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
12
|
|
|
use AppBundle\Traits\TimestampableTrait; |
13
|
|
|
use AppBundle\Traits\DeletedByTrait; |
14
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy; |
15
|
|
|
use JMS\Serializer\Annotation\Expose; |
16
|
|
|
use JMS\Serializer\Annotation\Type; |
17
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
18
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface; |
19
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @ORM\Table(name="employees") |
23
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\EmployeeRepository") |
24
|
|
|
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) |
25
|
|
|
* @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\EmployeeTranslation") |
26
|
|
|
* @ExclusionPolicy("all") |
27
|
|
|
*/ |
28
|
|
|
class Employee extends AbstractPersonalTranslatable implements TranslatableInterface |
29
|
|
|
{ |
30
|
|
|
use TimestampableTrait, BlameableEntity, DeletedByTrait; |
31
|
|
|
|
32
|
|
|
const POSITION_ACTOR = 'actor'; |
33
|
|
|
const POSITION_ACTRESS = 'actress'; |
34
|
|
|
const POSITION_THEATRE_DIRECTOR = 'theatre_director'; // |
35
|
|
|
const POSITION_THEATRE_DIRECTOR_ART_DIRECTOR = 'theatre_director_art_director'; // |
36
|
|
|
const POSITION_ACTING_ARTISTIC_DIRECTOR = 'acting_artistic_director'; // |
37
|
|
|
const POSITION_PRODUCTION_DIRECTOR = 'production_director'; |
38
|
|
|
const POSITION_MAIN_ARTIST = 'main_artist'; |
39
|
|
|
const POSITION_COSTUMER = 'costumer'; |
40
|
|
|
const POSITION_ARTISTIC_DIRECTOR = 'artistic_director'; |
41
|
|
|
const POSITION_MAIN_CHOREOGPAPHER = 'main_choreographer'; |
42
|
|
|
const POSITION_HEAD_OF_THE_LITERARY_AND_DRAMATIC_PART = 'head_of_the_literary_and_dramatic_part'; |
43
|
|
|
const POSITION_CONDUCTOR = 'conductor'; |
44
|
|
|
const POSITION_ACCOMPANIST = 'accompanist'; |
45
|
|
|
const POSITION_HEAD_CHOREOGRAPHER = 'head_choreographer'; |
46
|
|
|
const POSITION_ART_DIRECTOR = 'art_director'; |
47
|
|
|
const POSITION_STAGED = 'staged'; |
48
|
|
|
const POSITION_ACCOMPANIST_SINGING_CLASS = 'accompanist_singing_class'; |
49
|
|
|
const POSITION_HEAD_OF_TROUPE = 'head_of_troupe'; |
50
|
|
|
const POSITION_HEAD_OF_ARTISTIC_STAGING_PART = 'head_of_artistic_staging_part'; |
51
|
|
|
const POSITION_STAGE_MANAGER = 'stage_manager'; |
52
|
|
|
const POSITION_LEADING_ARTIST_SCENE = 'leading_artist_scene'; |
53
|
|
|
const POSITION_ACTOR_HIGHER_CATEGORY = 'actor_higher_category'; |
54
|
|
|
const POSITION_ACTOR_FIRST_CATEGORY = 'actor_first_category'; |
55
|
|
|
const POSITION_ACTOR_SINGER_SOLOIST_HIGHER_CATEGORY = 'actor_singer_soloist_higher_category'; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var integer |
59
|
|
|
* @ORM\Column(name="id", type="integer") |
60
|
|
|
* @ORM\Id |
61
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
62
|
|
|
*/ |
63
|
|
|
private $id; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var string |
67
|
|
|
* @Gedmo\Translatable |
68
|
|
|
* @Assert\NotBlank() |
69
|
|
|
* @ORM\Column(type="string", length=255) |
70
|
|
|
* @Type("string") |
71
|
|
|
* @Expose |
72
|
|
|
*/ |
73
|
|
|
private $firstName; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @var string |
77
|
|
|
* @Gedmo\Translatable |
78
|
|
|
* @Assert\NotBlank() |
79
|
|
|
* @ORM\Column(type="string", length=255) |
80
|
|
|
* @Type("string") |
81
|
|
|
* @Expose |
82
|
|
|
*/ |
83
|
|
|
private $lastName; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var /Datetime |
87
|
|
|
* @Assert\NotBlank() |
88
|
|
|
* @ORM\Column(type="datetime") |
89
|
|
|
* @Type("DateTime") |
90
|
|
|
* @Expose |
91
|
|
|
*/ |
92
|
|
|
private $dob; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @var string |
96
|
|
|
* @ORM\Column(type="string", length=255) |
97
|
|
|
* @Type("string") |
98
|
|
|
* @Expose |
99
|
|
|
*/ |
100
|
|
|
private $position; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @var string |
104
|
|
|
* @Gedmo\Translatable |
105
|
|
|
* @ORM\Column(type="text", nullable=true) |
106
|
|
|
* @Type("string") |
107
|
|
|
* @Expose |
108
|
|
|
*/ |
109
|
|
|
private $biography; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @var ArrayCollection|Role[] |
113
|
|
|
* |
114
|
|
|
* @ORM\OneToMany( |
115
|
|
|
* targetEntity="AppBundle\Entity\Role", |
116
|
|
|
* mappedBy="employee", |
117
|
|
|
* cascade={"persist", "remove"}, |
118
|
|
|
* orphanRemoval=true |
119
|
|
|
* ) |
120
|
|
|
*/ |
121
|
|
|
private $roles; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @var ArrayCollection|GalleryHasMedia[] |
125
|
|
|
* |
126
|
|
|
* @ORM\ManyToMany(targetEntity="Application\Sonata\MediaBundle\Entity\GalleryHasMedia", cascade={"persist"}) |
127
|
|
|
* @ORM\JoinTable(name="employee_galleryHasMedia", |
128
|
|
|
* joinColumns={@ORM\JoinColumn(name="employee_id",referencedColumnName="id")}, |
129
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="galleryHasMedia_id",referencedColumnName="id")} |
130
|
|
|
* ) |
131
|
|
|
*/ |
132
|
|
|
private $galleryHasMedia; |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @var array |
136
|
|
|
* @Expose |
137
|
|
|
* @Type("array") |
138
|
|
|
* @SerializedName("gallery") |
139
|
|
|
*/ |
140
|
|
|
public $galleryHasMediaThumbnails; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @Gedmo\Slug(fields={"firstName", "lastName"}) |
144
|
|
|
* @ORM\Column(name="slug", type="string", length=255) |
145
|
|
|
* @Type("string") |
146
|
|
|
* @Expose |
147
|
|
|
*/ |
148
|
|
|
private $slug; |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @var |
152
|
|
|
* |
153
|
|
|
* @ORM\OneToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"}) |
154
|
|
|
* @ORM\JoinColumn(name="avatar_id", referencedColumnName="id") |
155
|
|
|
*/ |
156
|
|
|
private $avatar; |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @var array |
160
|
|
|
* @Expose |
161
|
|
|
* @Type("array") |
162
|
|
|
* @SerializedName("avatar") |
163
|
|
|
*/ |
164
|
|
|
public $avatarThumbnails; |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @var ArrayCollection|EmployeeTranslation[] |
168
|
|
|
* |
169
|
|
|
* @ORM\OneToMany( |
170
|
|
|
* targetEntity="AppBundle\Entity\Translations\EmployeeTranslation", |
171
|
|
|
* mappedBy="object", |
172
|
|
|
* cascade={"persist", "remove"} |
173
|
|
|
* ) |
174
|
|
|
*/ |
175
|
|
|
protected $translations; |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Constructor |
179
|
|
|
*/ |
180
|
1 |
|
public function __construct() |
181
|
|
|
{ |
182
|
1 |
|
parent::__construct(); |
183
|
1 |
|
$this->roles = new ArrayCollection(); |
184
|
1 |
|
$this->galleryHasMedia = new ArrayCollection(); |
185
|
1 |
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Unset translations |
189
|
|
|
* |
190
|
|
|
* @return Employee |
191
|
|
|
*/ |
192
|
5 |
|
public function unsetTranslations() |
193
|
|
|
{ |
194
|
5 |
|
$this->translations = null; |
195
|
|
|
|
196
|
5 |
|
return $this; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Get id |
201
|
|
|
* |
202
|
|
|
* @return integer |
203
|
|
|
*/ |
204
|
2 |
|
public function getId() |
205
|
|
|
{ |
206
|
2 |
|
return $this->id; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* Get firstName |
211
|
|
|
* |
212
|
|
|
* @return string |
213
|
|
|
*/ |
214
|
6 |
|
public function getFirstName() |
215
|
|
|
{ |
216
|
6 |
|
return $this->firstName; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Set firstName |
221
|
|
|
* |
222
|
|
|
* @param string $firstName |
223
|
|
|
* @return Employee |
224
|
|
|
*/ |
225
|
|
|
public function setFirstName($firstName) |
226
|
|
|
{ |
227
|
|
|
$this->firstName = $firstName; |
228
|
|
|
|
229
|
|
|
return $this; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Get lastName |
234
|
|
|
* |
235
|
|
|
* @return string |
236
|
|
|
*/ |
237
|
6 |
|
public function getLastName() |
238
|
|
|
{ |
239
|
6 |
|
return $this->lastName; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* Set lastName |
244
|
|
|
* |
245
|
|
|
* @param string $lastName |
246
|
|
|
* @return Employee |
247
|
|
|
*/ |
248
|
|
|
public function setLastName($lastName) |
249
|
|
|
{ |
250
|
|
|
$this->lastName = $lastName; |
251
|
|
|
|
252
|
|
|
return $this; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Get dob |
257
|
|
|
* |
258
|
|
|
* @return \DateTime |
259
|
|
|
*/ |
260
|
3 |
|
public function getDob() |
261
|
|
|
{ |
262
|
3 |
|
return $this->dob; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* Set dob |
267
|
|
|
* |
268
|
|
|
* @param \DateTime $dob |
269
|
|
|
* @return Employee |
270
|
|
|
*/ |
271
|
|
|
public function setDob($dob) |
272
|
|
|
{ |
273
|
|
|
$this->dob = $dob; |
274
|
|
|
|
275
|
|
|
return $this; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* Get position |
280
|
|
|
* |
281
|
|
|
* @return string |
282
|
|
|
*/ |
283
|
7 |
|
public function getPosition() |
284
|
|
|
{ |
285
|
7 |
|
return $this->position; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Set position |
290
|
|
|
* |
291
|
|
|
* @param string $position |
292
|
|
|
* @return Employee |
293
|
|
|
*/ |
294
|
4 |
|
public function setPosition($position) |
295
|
|
|
{ |
296
|
4 |
|
$this->position = $position; |
297
|
|
|
|
298
|
4 |
|
return $this; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* Get biography |
303
|
|
|
* |
304
|
|
|
* @return string |
305
|
|
|
*/ |
306
|
1 |
|
public function getBiography() |
307
|
|
|
{ |
308
|
1 |
|
return $this->biography; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* Set biography |
313
|
|
|
* |
314
|
|
|
* @param string $biography |
315
|
|
|
* @return Employee |
316
|
|
|
*/ |
317
|
|
|
public function setBiography($biography) |
318
|
|
|
{ |
319
|
|
|
$this->biography = $biography; |
320
|
|
|
|
321
|
|
|
return $this; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* Add role |
326
|
|
|
* |
327
|
|
|
* @param Role $role |
328
|
|
|
* @return Employee |
329
|
|
|
*/ |
330
|
|
|
public function addRole(Role $role) |
331
|
|
|
{ |
332
|
|
|
$this->roles[] = $role; |
333
|
|
|
|
334
|
|
|
return $this; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Remove role |
339
|
|
|
* |
340
|
|
|
* @param Role $role |
341
|
|
|
*/ |
342
|
|
|
public function removeRole(Role $role) |
343
|
|
|
{ |
344
|
|
|
$this->roles->removeElement($role); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* Get roles |
349
|
|
|
* |
350
|
|
|
* @return \Doctrine\Common\Collections\Collection |
351
|
|
|
*/ |
352
|
3 |
|
public function getRoles() |
353
|
|
|
{ |
354
|
3 |
|
return $this->roles; |
355
|
|
|
} |
356
|
|
|
|
357
|
5 |
|
public function __toString() |
358
|
|
|
{ |
359
|
5 |
|
return $this->getFirstName().' '.$this->getLastName(); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
/** |
363
|
|
|
* Get slug |
364
|
|
|
* |
365
|
|
|
* @return string |
366
|
|
|
*/ |
367
|
2 |
|
public function getSlug() |
368
|
|
|
{ |
369
|
2 |
|
return $this->slug; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* Set slug |
374
|
|
|
* |
375
|
|
|
* @param string $slug |
376
|
|
|
* @return Employee |
377
|
|
|
*/ |
378
|
|
|
public function setSlug($slug) |
379
|
|
|
{ |
380
|
|
|
$this->slug = $slug; |
381
|
|
|
|
382
|
|
|
return $this; |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
/** |
386
|
|
|
* @return mixed |
387
|
|
|
*/ |
388
|
7 |
|
public function getAvatar() |
389
|
|
|
{ |
390
|
7 |
|
return $this->avatar; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
/** |
394
|
|
|
* @param mixed $avatar |
395
|
|
|
* @return $this |
396
|
|
|
*/ |
397
|
|
|
public function setAvatar($avatar) |
398
|
|
|
{ |
399
|
|
|
$this->avatar = $avatar; |
400
|
|
|
|
401
|
|
|
return $this; |
402
|
|
|
} |
403
|
|
|
|
404
|
3 |
|
public static function getPositions() |
405
|
|
|
{ |
406
|
|
|
return [ |
407
|
3 |
|
self::POSITION_ACTOR => 'actor', |
408
|
3 |
|
self::POSITION_ACTRESS => 'actress', |
409
|
3 |
|
self::POSITION_THEATRE_DIRECTOR => 'theatre_director', |
410
|
3 |
|
self::POSITION_THEATRE_DIRECTOR_ART_DIRECTOR => 'theatre_director_art_director', |
411
|
3 |
|
self::POSITION_ACTING_ARTISTIC_DIRECTOR => 'acting_artistic_director', |
412
|
3 |
|
self::POSITION_PRODUCTION_DIRECTOR => 'production_director', |
413
|
3 |
|
self::POSITION_MAIN_ARTIST => 'main_artist', |
414
|
3 |
|
self::POSITION_COSTUMER => 'costumer', |
415
|
3 |
|
self::POSITION_ARTISTIC_DIRECTOR => 'artistic_director', |
416
|
3 |
|
self::POSITION_MAIN_CHOREOGPAPHER => 'main_choreographer', |
417
|
3 |
|
self::POSITION_HEAD_OF_THE_LITERARY_AND_DRAMATIC_PART => 'head_of_the_literary_and_dramatic_part', |
418
|
3 |
|
self::POSITION_CONDUCTOR => 'conductor', |
419
|
3 |
|
self::POSITION_ACCOMPANIST => 'accompanist', |
420
|
3 |
|
self::POSITION_HEAD_CHOREOGRAPHER => 'head_choreographer', |
421
|
3 |
|
self::POSITION_ART_DIRECTOR => 'art_director', |
422
|
3 |
|
self::POSITION_STAGED => 'staged', |
423
|
3 |
|
self::POSITION_ACCOMPANIST_SINGING_CLASS => 'accompanist_singing_class', |
424
|
3 |
|
self::POSITION_HEAD_OF_TROUPE => 'head_of_troupe', |
425
|
3 |
|
self::POSITION_HEAD_OF_ARTISTIC_STAGING_PART => 'head_of_artistic_staging_part', |
426
|
3 |
|
self::POSITION_STAGE_MANAGER => 'stage_manager', |
427
|
3 |
|
self::POSITION_LEADING_ARTIST_SCENE => 'leading_artist_scene', |
428
|
3 |
|
self::POSITION_ACTOR_HIGHER_CATEGORY => 'actor_higher_category', |
429
|
3 |
|
self::POSITION_ACTOR_FIRST_CATEGORY => 'actor_first_category', |
430
|
3 |
|
self::POSITION_ACTOR_SINGER_SOLOIST_HIGHER_CATEGORY => 'actor_singer_soloist_higher_category', |
431
|
|
|
]; |
432
|
|
|
} |
433
|
|
|
|
434
|
|
|
/** |
435
|
|
|
* Add galleryHasMedia |
436
|
|
|
* |
437
|
|
|
* @param \Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia |
438
|
|
|
* @return Employee |
439
|
|
|
*/ |
440
|
|
|
public function addGalleryHasMedia(\Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia) |
441
|
|
|
{ |
442
|
|
|
$this->galleryHasMedia[] = $galleryHasMedia; |
443
|
|
|
|
444
|
|
|
return $this; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Remove galleryHasMedia |
449
|
|
|
* |
450
|
|
|
* @param \Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia |
451
|
|
|
*/ |
452
|
|
|
public function removeGalleryHasMedia(\Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia) |
453
|
|
|
{ |
454
|
|
|
$this->galleryHasMedia->removeElement($galleryHasMedia); |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* Get galleryHasMedia |
459
|
|
|
* |
460
|
|
|
* @return \Doctrine\Common\Collections\Collection |
461
|
|
|
*/ |
462
|
4 |
|
public function getGalleryHasMedia() |
463
|
|
|
{ |
464
|
4 |
|
return $this->galleryHasMedia; |
465
|
|
|
} |
466
|
|
|
} |
467
|
|
|
|