Completed
Push — master ( 114d74...c7028a )
by Serhii
16:40 queued 11:25
created

Performance::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use AppBundle\Entity\Translations\PerformanceTranslation;
6
use AppBundle\Model\LinksTrait;
7
use Application\Sonata\MediaBundle\Entity\GalleryHasMedia;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\ORM\Mapping as ORM;
10
use Gedmo\Mapping\Annotation as Gedmo;
11
use Gedmo\Blameable\Traits\BlameableEntity;
12
use JMS\Serializer\Annotation\Accessor;
13
use JMS\Serializer\Annotation\SerializedName;
14
use Symfony\Component\Validator\Constraints as Assert;
15
use AppBundle\Traits\TimestampableTrait;
16
use AppBundle\Traits\DeletedByTrait;
17
use JMS\Serializer\Annotation\ExclusionPolicy;
18
use JMS\Serializer\Annotation\Expose;
19
use JMS\Serializer\Annotation\Type;
20
use AppBundle\Validator\MinSizeSliderImage;
21
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface;
22
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable;
23
24
/**
25
 * @ORM\Table(name="performances")
26
 * @ORM\Entity(repositoryClass="AppBundle\Repository\PerformanceRepository")
27
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
28
 * @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\PerformanceTranslation")
29
 * @ExclusionPolicy("all")
30
 * @MinSizeSliderImage()
31
 * @SuppressWarnings(PHPMD.TooManyFields)
32
 */
33
class Performance extends AbstractPersonalTranslatable implements TranslatableInterface
34
{
35
    use TimestampableTrait, LinksTrait, BlameableEntity, DeletedByTrait;
36
37
    /**
38
     * @var integer
39
     *
40
     * @ORM\Column(name="id", type="integer")
41
     * @ORM\Id
42
     * @ORM\GeneratedValue(strategy="AUTO")
43
     */
44
    private $id;
45
46
    /**
47
     * @var string
48
     * @Gedmo\Translatable
49
     * @Assert\NotBlank()
50
     * @ORM\Column(type="string", length=255)
51
     * @Type("string")
52
     * @Expose
53
     */
54
    private $title;
55
56
    /**
57
     * @var string
58
     * @Gedmo\Translatable
59
     * @ORM\Column(type="text", length=255, nullable=true)
60
     * @Type("string")
61
     * @Expose
62
     */
63
    private $type;
64
65
    /**
66
     * @var string
67
     * @Gedmo\Translatable
68
     * @Assert\NotBlank()
69
     * @ORM\Column(type="text", nullable=true)
70
     * @Type("string")
71
     * @Expose
72
     */
73
    private $description;
74
75
    /**
76
     * @var /Datetime
77
     *
78
     * @Assert\NotBlank()
79
     * @ORM\Column(type="datetime")
80
     * @Type("DateTime")
81
     * @Expose
82
     */
83
    private $premiere;
84
85
    /**
86
     * @var
87
     *
88
     * @ORM\OneToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"})
89
     * @ORM\JoinColumn(name="mainPicture_id", referencedColumnName="id", nullable=true)
90
     */
91
    private $mainPicture;
92
93
    /**
94
     * @var
95
     *
96
     * @ORM\OneToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"})
97
     * @ORM\JoinColumn(name="sliderImage_id", referencedColumnName="id", nullable=true)
98
     */
99
    private $sliderImage;
100
101
    /**
102
     * @var array
103
     * @Expose
104
     * @Type("array")
105
     * @SerializedName("mainPicture")
106
     * @Accessor(getter="getMainPicture")
107
     */
108
    public $mainPictureThumbnails;
109
110
    /**
111
     * @var array
112
     * @Expose
113
     * @Type("array")
114
     * @SerializedName("sliderImage")
115
     * @Accessor(getter="getSliderImage")
116
     */
117
    public $sliderImageThumbnails;
118
119
    /**
120
     * @var ArrayCollection|PerformanceEvent[]
121
     *
122
     * @ORM\OneToMany(
123
     *     targetEntity="AppBundle\Entity\PerformanceEvent",
124
     *     mappedBy="performance",
125
     *     cascade={"persist"},
126
     *     orphanRemoval=true
127
     * )
128
     */
129
    private $performanceEvents;
130
131
    /**
132
     * @var ArrayCollection|Role[]
133
     *
134
     * @ORM\OneToMany(
135
     *     targetEntity="AppBundle\Entity\Role",
136
     *     mappedBy="performance",
137
     *     cascade={"persist", "remove"},
138
     *     orphanRemoval=true
139
     * )
140
     */
141
    private $roles;
142
143
    /**
144
     * @var ArrayCollection|GalleryHasMedia[]
145
     *
146
     * @ORM\ManyToMany(targetEntity="Application\Sonata\MediaBundle\Entity\GalleryHasMedia", cascade={"persist"})
147
     * @ORM\JoinTable(name="performance_galleryHasMedia",
148
     *     joinColumns={@ORM\JoinColumn(name="performance_id",referencedColumnName="id")},
149
     *     inverseJoinColumns={@ORM\JoinColumn(name="galleryHasMedia_id",referencedColumnName="id")}
150
     *     )
151
     */
152
    private $galleryHasMedia;
153
154
    /**
155
     * @var array
156
     * @Expose
157
     * @Type("array")
158
     * @SerializedName("gallery")
159
     * @Accessor(getter="getGalleryHasMedia")
160
     */
161
    public $galleryHasMediaThumbnails;
162
163
    /**
164
     * @Gedmo\Slug(fields={"title"})
165
     * @ORM\Column(name="slug", type="string", length=255)
166
     * @Type("string")
167
     * @Expose
168
     */
169
    private $slug;
170
171
    /**
172
     * @var ArrayCollection|PerformanceTranslation[]
173
     *
174
     * @ORM\OneToMany(
175
     *     targetEntity="AppBundle\Entity\Translations\PerformanceTranslation",
176
     *     mappedBy="object",
177
     *     cascade={"persist", "remove"}
178
     * )
179
     */
180
    protected $translations;
181
182
    /**
183
     * @var \AppBundle\Entity\History
184
     *
185
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\History", inversedBy="performances")
186
     */
187
    protected $festival;
188
189
    /**
190
     * Constructor
191
     */
192 1
    public function __construct()
193
    {
194 1
        parent::__construct();
195 1
        $this->performanceEvents = new ArrayCollection();
196 1
        $this->roles = new ArrayCollection();
197 1
        $this->galleryHasMedia = new ArrayCollection();
198 1
    }
199
200
    /**
201
     * Unset translations
202
     *
203
     * @return Performance
204
     */
205 8
    public function unsetTranslations()
206
    {
207 8
        $this->translations = null;
208
209 8
        return $this;
210
    }
211
212
    /**
213
     * Get id
214
     *
215
     * @return integer
216
     */
217 2
    public function getId()
218
    {
219 2
        return $this->id;
220
    }
221
222
    /**
223
     * Get type
224
     *
225
     * @return string
226
     */
227 3
    public function getType()
228
    {
229 3
        return $this->type;
230
    }
231
232
    /**
233
     * Set type
234
     *
235
     * @param  string      $type
236
     * @return Performance
237
     */
238
    public function setType($type)
239
    {
240
        $this->type = $type;
241
242
        return $this;
243
    }
244
245
    /**
246
     * Get description
247
     *
248
     * @return string
249
     */
250 1
    public function getDescription()
251
    {
252 1
        return $this->description;
253
    }
254
255
    /**
256
     * Set description
257
     *
258
     * @param  string      $description
259
     * @return Performance
260
     */
261
    public function setDescription($description)
262
    {
263
        $this->description = $description;
264
265
        return $this;
266
    }
267
268
    /**
269
     * Get premiere
270
     *
271
     * @return \DateTime
272
     */
273 3
    public function getPremiere()
274
    {
275 3
        return $this->premiere;
276
    }
277
278
    /**
279
     * Set premiere
280
     *
281
     * @param  \DateTime   $premiere
282
     * @return Performance
283
     */
284
    public function setPremiere($premiere)
285
    {
286
        $this->premiere = $premiere;
287
288
        return $this;
289
    }
290
291
    /**
292
     * Get mainPicture
293
     *
294
     * @return \Application\Sonata\MediaBundle\Entity\Media
295
     */
296 13
    public function getMainPicture()
297
    {
298 13
        return $this->mainPicture;
299
    }
300
301
    /**
302
     * Set mainPicture
303
     *
304
     * @param  \Application\Sonata\MediaBundle\Entity\Media $mainPicture
305
     * @return Performance
306
     */
307
    public function setMainPicture(\Application\Sonata\MediaBundle\Entity\Media $mainPicture = null)
308
    {
309
        $this->mainPicture = $mainPicture;
310
311
        return $this;
312
    }
313
314
    /**
315
     * Get sliderImage
316
     *
317
     * @return \Application\Sonata\MediaBundle\Entity\Media
318
     */
319 11
    public function getSliderImage()
320
    {
321 11
        return $this->sliderImage;
322
    }
323
324
    /**
325
     * Set sliderImage
326
     *
327
     * @param  \Application\Sonata\MediaBundle\Entity\Media $sliderImage
328
     * @return Performance
329
     */
330
    public function setSliderImage(\Application\Sonata\MediaBundle\Entity\Media $sliderImage = null)
331
    {
332
        $this->sliderImage = $sliderImage;
333
334
        return $this;
335
    }
336
337
    /**
338
     * Get slug
339
     *
340
     * @return string
341
     */
342 5
    public function getSlug()
343
    {
344 5
        return $this->slug;
345
    }
346
347
    /**
348
     * Set slug
349
     *
350
     * @param  string      $slug
351
     * @return Performance
352
     */
353
    public function setSlug($slug)
354
    {
355
        $this->slug = $slug;
356
357
        return $this;
358
    }
359
360
    /**
361
     * Add performanceEvent
362
     *
363
     * @param  \AppBundle\Entity\PerformanceEvent $performanceEvent
364
     * @return Performance
365
     */
366
    public function addPerformanceEvent(\AppBundle\Entity\PerformanceEvent $performanceEvent)
367
    {
368
        $this->performanceEvents[] = $performanceEvent;
369
370
        return $this;
371
    }
372
373
    /**
374
     * Remove performanceEvent
375
     *
376
     * @param \AppBundle\Entity\PerformanceEvent $performanceEvent
377
     */
378
    public function removePerformanceEvent(\AppBundle\Entity\PerformanceEvent $performanceEvent)
379
    {
380
        $this->performanceEvents->removeElement($performanceEvent);
381
    }
382
383
    /**
384
     * Get performanceEvents
385
     *
386
     * @return \Doctrine\Common\Collections\Collection
387
     */
388 2
    public function getPerformanceEvents()
389
    {
390 2
        return $this->performanceEvents;
391
    }
392
393
    /**
394
     * Add role
395
     *
396
     * @param  \AppBundle\Entity\Role $role
397
     * @return Performance
398
     */
399
    public function addRole(\AppBundle\Entity\Role $role)
400
    {
401
        $role->setPerformance($this);
402
        $this->roles[] = $role;
403
404
        return $this;
405
    }
406
407
    /**
408
     * Remove role
409
     *
410
     * @param \AppBundle\Entity\Role $role
411
     */
412
    public function removeRole(\AppBundle\Entity\Role $role)
413
    {
414
        $this->roles->removeElement($role);
415
    }
416
417
    /**
418
     * Get roles
419
     *
420
     * @return \Doctrine\Common\Collections\Collection
421
     */
422 3
    public function getRoles()
423
    {
424 3
        return $this->roles;
425
    }
426
427 7
    public function __toString()
428
    {
429 7
        return $this->getTitle();
430
    }
431
432
    /**
433
     * Get title
434
     *
435
     * @return string
436
     */
437 8
    public function getTitle()
438
    {
439 8
        return $this->title;
440
    }
441
442
    /**
443
     * Set title
444
     *
445
     * @param  string      $title
446
     * @return Performance
447
     */
448
    public function setTitle($title)
449
    {
450
        $this->title = $title;
451
452
        return $this;
453
    }
454
455
    /**
456
     * Add galleryHasMedia
457
     *
458
     * @param  \Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia
459
     * @return Performance
460
     */
461
    public function addGalleryHasMedia(\Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia)
462
    {
463
        $this->galleryHasMedia[] = $galleryHasMedia;
464
465
        return $this;
466
    }
467
468
    /**
469
     * Remove galleryHasMedia
470
     *
471
     * @param \Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia
472
     */
473
    public function removeGalleryHasMedia(\Application\Sonata\MediaBundle\Entity\GalleryHasMedia $galleryHasMedia)
474
    {
475
        $this->galleryHasMedia->removeElement($galleryHasMedia);
476
    }
477
478
    /**
479
     * Get galleryHasMedia
480
     *
481
     * @return \Doctrine\Common\Collections\Collection
482
     */
483 10
    public function getGalleryHasMedia()
484
    {
485 10
        return $this->galleryHasMedia;
486
    }
487
488
    /**
489
     * @return History
490
     */
491 3
    public function getFestival()
492
    {
493 3
        return $this->festival;
494
    }
495
496
    /**
497
     * @param History $festival
498
     * @return $this
499
     */
500
    public function setFestival($festival)
501
    {
502
        $this->festival = $festival;
503
504
        return $this;
505
    }
506
}
507