Completed
Pull Request — master (#162)
by
unknown
03:18
created

Performance::setSliderImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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