1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\Collection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
9
|
|
|
use Gedmo\Blameable\Traits\BlameableEntity; |
10
|
|
|
use JMS\Serializer\Annotation as Serializer; |
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\Accessor; |
18
|
|
|
use AppBundle\Validator\TwoPerformanceEventsPerDay; |
19
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface; |
20
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @ORM\Table(name="performance_schedule") |
24
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\PerformanceEventRepository") |
25
|
|
|
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) |
26
|
|
|
* @ExclusionPolicy("all") |
27
|
|
|
* @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\PerformanceEventTranslation") |
28
|
|
|
* @TwoPerformanceEventsPerDay() |
29
|
|
|
*/ |
30
|
|
|
class PerformanceEvent extends AbstractPersonalTranslatable implements TranslatableInterface |
31
|
|
|
{ |
32
|
|
|
use TimestampableTrait, BlameableEntity, DeletedByTrait; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var integer |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(name="id", type="integer") |
38
|
|
|
* @ORM\Id |
39
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
40
|
|
|
* |
41
|
|
|
* @Serializer\Groups({"get_ticket"}) |
42
|
|
|
* @Type("integer") |
43
|
|
|
* @Expose |
44
|
|
|
*/ |
45
|
|
|
private $id; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var Performance |
49
|
|
|
* |
50
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Performance", inversedBy="performanceEvents") |
51
|
|
|
* |
52
|
|
|
* @Serializer\Groups({"get_ticket"}) |
53
|
|
|
* @Type("AppBundle\Entity\Performance") |
54
|
|
|
* @Expose |
55
|
|
|
*/ |
56
|
|
|
private $performance; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var /Datetime |
60
|
|
|
* |
61
|
|
|
* @Assert\NotBlank() |
62
|
|
|
* @ORM\Column(type="datetime") |
63
|
|
|
* |
64
|
|
|
* @Serializer\Groups({"get_ticket"}) |
65
|
|
|
* @Type("DateTime") |
66
|
|
|
* @Expose |
67
|
|
|
*/ |
68
|
|
|
private $dateTime; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var Venue |
72
|
|
|
* |
73
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Venue", inversedBy="performanceEvents") |
74
|
|
|
* |
75
|
|
|
* @Serializer\Groups({"get_ticket"}) |
76
|
|
|
* @Type("AppBundle\Entity\Venue") |
77
|
|
|
* @Expose |
78
|
|
|
*/ |
79
|
|
|
private $venue; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var int |
83
|
|
|
* |
84
|
|
|
* @Serializer\Groups({"get_ticket"}) |
85
|
|
|
* @Type("integer") |
86
|
|
|
* @Expose |
87
|
|
|
* @Accessor(getter="getYear") |
88
|
|
|
*/ |
89
|
|
|
private $year; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var int |
93
|
|
|
* |
94
|
|
|
* @Serializer\Groups({"get_ticket"}) |
95
|
|
|
* @Expose |
96
|
|
|
* @Accessor(getter="getMonth") |
97
|
|
|
*/ |
98
|
|
|
private $month; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @var int |
102
|
|
|
* |
103
|
|
|
* @Serializer\Groups({"get_ticket"}) |
104
|
|
|
* @Expose |
105
|
|
|
* @Accessor(getter="getDay") |
106
|
|
|
*/ |
107
|
|
|
private $day; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @var string |
111
|
|
|
* |
112
|
|
|
* @Serializer\Groups({"get_ticket"}) |
113
|
|
|
* @Expose |
114
|
|
|
* @Accessor(getter="getTime") |
115
|
|
|
*/ |
116
|
|
|
private $time; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @var string |
120
|
|
|
* |
121
|
|
|
* @Serializer\Groups({"get_ticket"}) |
122
|
|
|
* @ORM\Column(type="string", length=10, nullable=true) |
123
|
|
|
* @Assert\Length(max="10", min="3") |
124
|
|
|
* @Type("string") |
125
|
|
|
* @Expose |
126
|
|
|
*/ |
127
|
|
|
private $seriesNumber; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @var \DateTime |
131
|
|
|
* @Assert\DateTime() |
132
|
|
|
* @ORM\Column(type="datetime", nullable=true) |
133
|
|
|
* |
134
|
|
|
* @Serializer\Groups({"get_ticket"}) |
135
|
|
|
* @Type("DateTime") |
136
|
|
|
* @Expose |
137
|
|
|
*/ |
138
|
|
|
private $seriesDate; |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @var boolean |
142
|
|
|
* @ORM\Column(type="boolean", nullable=true, options={"default" : false}) |
143
|
|
|
* |
144
|
|
|
* @Serializer\Groups({"get_ticket"}) |
145
|
|
|
* @Type("boolean") |
146
|
|
|
* @Expose |
147
|
|
|
*/ |
148
|
|
|
private $enableSale; |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @var Collection |
152
|
|
|
* |
153
|
|
|
* @ORM\ManyToMany( |
154
|
|
|
* targetEntity="AppBundle\Entity\RowsForSale", |
155
|
|
|
* inversedBy="performanceEvent", |
156
|
|
|
* cascade={"persist","detach","merge"} |
157
|
|
|
* ) |
158
|
|
|
* @Serializer\Groups({"get_ticket"}) |
159
|
|
|
* @Type("AppBundle\Entity\RowsForSale") |
160
|
|
|
* @Expose |
161
|
|
|
*/ |
162
|
|
|
protected $rowsForSale; |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @var ArrayCollection|Translation[] |
166
|
|
|
* |
167
|
|
|
* @ORM\OneToMany( |
168
|
|
|
* targetEntity="AppBundle\Entity\Translations\PerformanceEventTranslation", |
169
|
|
|
* mappedBy="object", |
170
|
|
|
* cascade={"persist", "remove"} |
171
|
|
|
* ) |
172
|
|
|
*/ |
173
|
|
|
protected $translations; |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @var ArrayCollection|PriceCategory[] |
177
|
|
|
* |
178
|
|
|
* @Assert\Valid |
179
|
|
|
* @ORM\OneToMany( |
180
|
|
|
* targetEntity="AppBundle\Entity\PriceCategory", |
181
|
|
|
* mappedBy="performanceEvent", |
182
|
|
|
* cascade={"persist"}, |
183
|
|
|
* orphanRemoval=true |
184
|
|
|
* ) |
185
|
|
|
*/ |
186
|
|
|
protected $priceCategories; |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @var boolean |
190
|
|
|
*/ |
191
|
|
|
protected $sale; |
192
|
|
|
|
193
|
8 |
|
public function __construct() |
194
|
|
|
{ |
195
|
8 |
|
parent::__construct(); |
196
|
8 |
|
$this->priceCategories = new ArrayCollection(); |
197
|
8 |
|
$this->seriesDate = new \DateTime(); |
198
|
8 |
|
$this->rowsForSale = new ArrayCollection(); |
199
|
8 |
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Unset translations |
203
|
|
|
* |
204
|
|
|
* @return PerformanceEvent |
205
|
|
|
*/ |
206
|
7 |
|
public function unsetTranslations() |
207
|
|
|
{ |
208
|
7 |
|
$this->translations = null; |
209
|
|
|
|
210
|
7 |
|
return $this; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Get id |
215
|
|
|
* |
216
|
|
|
* @return integer |
217
|
|
|
*/ |
218
|
14 |
|
public function getId() |
219
|
|
|
{ |
220
|
14 |
|
return $this->id; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Set dateTime |
225
|
|
|
* |
226
|
|
|
* @param \DateTime $dateTime |
227
|
|
|
* @return PerformanceEvent |
228
|
|
|
*/ |
229
|
8 |
|
public function setDateTime($dateTime) |
230
|
|
|
{ |
231
|
8 |
|
$this->dateTime = $dateTime; |
232
|
|
|
|
233
|
8 |
|
return $this; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Get dateTime |
238
|
|
|
* |
239
|
|
|
* @return \DateTime |
240
|
|
|
*/ |
241
|
18 |
|
public function getDateTime() |
242
|
|
|
{ |
243
|
18 |
|
return $this->dateTime; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Set performance |
248
|
|
|
* |
249
|
|
|
* @param \AppBundle\Entity\Performance $performance |
250
|
|
|
* @return PerformanceEvent |
251
|
|
|
*/ |
252
|
1 |
|
public function setPerformance(\AppBundle\Entity\Performance $performance = null) |
253
|
|
|
{ |
254
|
1 |
|
$this->performance = $performance; |
255
|
|
|
|
256
|
1 |
|
return $this; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* Get performance |
261
|
|
|
* |
262
|
|
|
* @return \AppBundle\Entity\Performance |
263
|
|
|
*/ |
264
|
9 |
|
public function getPerformance() |
265
|
|
|
{ |
266
|
9 |
|
return $this->performance; |
267
|
|
|
} |
268
|
|
|
|
269
|
3 |
|
public function __toString() |
270
|
|
|
{ |
271
|
3 |
|
if ($this->getDateTime()) { |
272
|
3 |
|
return $this->getDateTime()->format('d-m-Y H:i'); |
273
|
|
|
} |
274
|
|
|
|
275
|
1 |
|
return date("F j, Y, g:i a"); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* @return mixed |
280
|
|
|
*/ |
281
|
7 |
|
public function getYear() |
282
|
|
|
{ |
283
|
7 |
|
return $this->getDateTime()->format('Y'); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @param mixed $year |
288
|
|
|
*/ |
289
|
|
|
public function setYear($year) |
290
|
|
|
{ |
291
|
|
|
$this->year = $year; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @return int |
296
|
|
|
*/ |
297
|
7 |
|
public function getMonth() |
298
|
|
|
{ |
299
|
7 |
|
return $this->getDateTime()->format('n'); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* @param int $month |
304
|
|
|
*/ |
305
|
|
|
public function setMonth($month) |
306
|
|
|
{ |
307
|
|
|
$this->month = $month; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* @return int |
312
|
|
|
*/ |
313
|
7 |
|
public function getDay() |
314
|
|
|
{ |
315
|
7 |
|
return $this->getDateTime()->format('j'); |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* @param int $day |
320
|
|
|
*/ |
321
|
|
|
public function setDay($day) |
322
|
|
|
{ |
323
|
|
|
$this->day = $day; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* @return string |
328
|
|
|
*/ |
329
|
7 |
|
public function getTime() |
330
|
|
|
{ |
331
|
7 |
|
return $this->getDateTime()->format('G:i'); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @param string $time |
336
|
|
|
*/ |
337
|
|
|
public function setTime($time) |
338
|
|
|
{ |
339
|
|
|
$this->time = $time; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* @return Venue |
344
|
|
|
*/ |
345
|
12 |
|
public function getVenue() |
346
|
|
|
{ |
347
|
12 |
|
return $this->venue; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* @param Venue $venue |
352
|
|
|
* @return PerformanceEvent |
353
|
|
|
*/ |
354
|
1 |
|
public function setVenue(Venue $venue) |
355
|
|
|
{ |
356
|
1 |
|
$this->venue = $venue; |
357
|
|
|
|
358
|
1 |
|
return $this; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* @param PriceCategory $priceCategory |
363
|
|
|
* @return PerformanceEvent |
364
|
|
|
*/ |
365
|
|
|
public function addPriceCategory(PriceCategory $priceCategory) |
366
|
|
|
{ |
367
|
|
|
$this->priceCategories[] = $priceCategory; |
368
|
|
|
|
369
|
|
|
return $this; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* @param PriceCategory $priceCategory |
374
|
|
|
*/ |
375
|
|
|
public function removePriceCategories(PriceCategory $priceCategory) |
376
|
|
|
{ |
377
|
|
|
$this->priceCategories->removeElement($priceCategory); |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* @return Collection |
382
|
|
|
*/ |
383
|
2 |
|
public function getPriceCategories() |
384
|
|
|
{ |
385
|
2 |
|
return $this->priceCategories; |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
/** |
389
|
|
|
* @param PriceCategory[]|ArrayCollection $priceCategory |
390
|
|
|
*/ |
391
|
|
|
public function setPriceCategories($priceCategory) |
392
|
|
|
{ |
393
|
|
|
$this->priceCategories[] = $priceCategory; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* @return string |
398
|
|
|
*/ |
399
|
3 |
|
public function getSeriesNumber() |
400
|
|
|
{ |
401
|
3 |
|
return $this->seriesNumber; |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* @param string $seriesNumber |
406
|
|
|
*/ |
407
|
1 |
|
public function setSeriesNumber($seriesNumber) |
408
|
|
|
{ |
409
|
1 |
|
$this->seriesNumber = $seriesNumber; |
410
|
1 |
|
} |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* @return \DateTime |
414
|
|
|
*/ |
415
|
1 |
|
public function getSeriesDate() |
416
|
|
|
{ |
417
|
1 |
|
return $this->seriesDate; |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* @param \DateTime $seriesDate |
422
|
|
|
*/ |
423
|
1 |
|
public function setSeriesDate($seriesDate) |
424
|
|
|
{ |
425
|
1 |
|
$this->seriesDate = $seriesDate; |
426
|
1 |
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* @return boolean |
430
|
|
|
*/ |
431
|
2 |
|
public function isEnableSale() |
432
|
|
|
{ |
433
|
2 |
|
return $this->enableSale; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* @param boolean $enableSale |
438
|
|
|
*/ |
439
|
1 |
|
public function setEnableSale($enableSale) |
440
|
|
|
{ |
441
|
1 |
|
$this->enableSale = $enableSale; |
442
|
1 |
|
} |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* @return Collection |
446
|
|
|
*/ |
447
|
1 |
|
public function getRowsForSale() |
448
|
|
|
{ |
449
|
1 |
|
return $this->rowsForSale; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* @param RowsForSale $rowsForSale |
454
|
|
|
* @return PerformanceEvent |
455
|
|
|
*/ |
456
|
|
|
public function addRowsForSale(RowsForSale $rowsForSale) |
457
|
|
|
{ |
458
|
|
|
$this->rowsForSale[] = $rowsForSale; |
459
|
|
|
|
460
|
|
|
return $this; |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
/** |
464
|
|
|
* @param RowsForSale $rowsForSale |
465
|
|
|
*/ |
466
|
|
|
public function removeRowsForSale(RowsForSale $rowsForSale) |
467
|
|
|
{ |
468
|
|
|
$this->rowsForSale->removeElement($rowsForSale); |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* @return boolean |
473
|
|
|
*/ |
474
|
2 |
|
public function isSale() |
475
|
|
|
{ |
476
|
2 |
|
return $this->sale; |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
/** |
480
|
|
|
* @param boolean $sale |
481
|
|
|
*/ |
482
|
1 |
|
public function setSale($sale) |
483
|
|
|
{ |
484
|
1 |
|
$this->sale = $sale; |
485
|
1 |
|
} |
486
|
|
|
} |
487
|
|
|
|