1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
8
|
|
|
use Gedmo\Blameable\Traits\BlameableEntity; |
9
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
10
|
|
|
use App\Traits\TimestampableTrait; |
11
|
|
|
use App\Traits\DeletedByTrait; |
12
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy; |
13
|
|
|
use JMS\Serializer\Annotation\Expose; |
14
|
|
|
use JMS\Serializer\Annotation\Type; |
15
|
|
|
use JMS\Serializer\Annotation\Accessor; |
16
|
|
|
use App\Validator\TwoPerformanceEventsPerDay; |
17
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface; |
18
|
|
|
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @ORM\Table(name="performance_schedule", indexes={ |
22
|
|
|
* @ORM\Index(name="date_time_idx", columns={"dateTime"}), |
23
|
|
|
* @ORM\Index(name="performance_dateTime_idx", columns={"performance_id", "dateTime"}) |
24
|
|
|
* }) |
25
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\PerformanceEventRepository") |
26
|
|
|
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) |
27
|
|
|
* @ExclusionPolicy("all") |
28
|
|
|
* @Gedmo\TranslationEntity(class="App\Entity\Translations\PerformanceEventTranslation") |
29
|
|
|
* @TwoPerformanceEventsPerDay() |
30
|
|
|
*/ |
31
|
|
|
class PerformanceEvent extends AbstractPersonalTranslatable implements TranslatableInterface |
32
|
|
|
{ |
33
|
|
|
use TimestampableTrait, BlameableEntity, DeletedByTrait; |
34
|
|
|
|
35
|
|
|
const VENUE_PHILHARMONIC = "venue-philharmonic"; |
36
|
|
|
const VENUE_KULIC_HOUSE = "venue-kilic-house"; |
37
|
|
|
const VENUE_THEATRE = "venue-theatre"; |
38
|
|
|
const VENUE_SALUT = 'venue-salut'; |
39
|
|
|
const VENUE_PALAC_MOLODI = 'venue-palac_molodi'; |
40
|
|
|
const VENUE_CENTER_OF_KIDS_ARTS = 'venue-center_of_kids_arts'; |
41
|
|
|
const VENUE_CHERKASY_ART_MUSEUM = 'venue-cherkasy-art-museum'; |
42
|
|
|
const VENUE_NATIONS_FRIENDSHIP = 'venue-nations-friendship'; |
43
|
|
|
|
44
|
|
|
public static $venues = [ |
45
|
|
|
self::VENUE_PHILHARMONIC => self::VENUE_PHILHARMONIC, |
46
|
|
|
self::VENUE_KULIC_HOUSE => self::VENUE_KULIC_HOUSE, |
47
|
|
|
self::VENUE_THEATRE => self::VENUE_THEATRE, |
48
|
|
|
self::VENUE_SALUT => self::VENUE_SALUT, |
49
|
|
|
self::VENUE_PALAC_MOLODI => self::VENUE_PALAC_MOLODI, |
50
|
|
|
self::VENUE_CENTER_OF_KIDS_ARTS => self::VENUE_CENTER_OF_KIDS_ARTS, |
51
|
|
|
self::VENUE_CHERKASY_ART_MUSEUM => self::VENUE_CHERKASY_ART_MUSEUM, |
52
|
|
|
self::VENUE_NATIONS_FRIENDSHIP => self::VENUE_NATIONS_FRIENDSHIP, |
53
|
|
|
]; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var integer |
57
|
|
|
* |
58
|
|
|
* @ORM\Column(name="id", type="integer") |
59
|
|
|
* @ORM\Id |
60
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
61
|
|
|
* @Type("integer") |
62
|
|
|
* @Expose |
63
|
|
|
*/ |
64
|
|
|
private $id; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var Performance |
68
|
|
|
* |
69
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Performance", inversedBy="performanceEvents") |
70
|
|
|
* @Type("App\Entity\Performance") |
71
|
|
|
* @Expose |
72
|
|
|
*/ |
73
|
|
|
private $performance; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @var /Datetime |
77
|
|
|
* |
78
|
|
|
* @Assert\NotBlank() |
79
|
|
|
* @ORM\Column(type="datetime") |
80
|
|
|
* @Type("DateTime") |
81
|
|
|
* @Expose |
82
|
|
|
*/ |
83
|
|
|
private $dateTime; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Place where performance happens |
87
|
|
|
* @var string |
88
|
|
|
* @ORM\Column(type="string") |
89
|
|
|
* @Type("string") |
90
|
|
|
* @Expose |
91
|
|
|
*/ |
92
|
|
|
private $venue; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @var int |
96
|
|
|
* |
97
|
|
|
* @Type("integer") |
98
|
|
|
* @Expose |
99
|
|
|
* @Accessor(getter="getYear") |
100
|
|
|
*/ |
101
|
|
|
private $year; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @var int |
105
|
|
|
* |
106
|
|
|
* @Expose |
107
|
|
|
* @Accessor(getter="getMonth") |
108
|
|
|
*/ |
109
|
|
|
private $month; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @var int |
113
|
|
|
* |
114
|
|
|
* @Expose |
115
|
|
|
* @Accessor(getter="getDay") |
116
|
|
|
*/ |
117
|
|
|
private $day; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @var string |
121
|
|
|
* |
122
|
|
|
* @Expose |
123
|
|
|
* @Accessor(getter="getTime") |
124
|
|
|
*/ |
125
|
|
|
private $time; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @var string |
129
|
|
|
* @ORM\Column(type="string", nullable=true) |
130
|
|
|
* @Type("string") |
131
|
|
|
* @Expose |
132
|
|
|
*/ |
133
|
|
|
private $buyTicketLink; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @var ArrayCollection |
137
|
|
|
* |
138
|
|
|
* @ORM\OneToMany( |
139
|
|
|
* targetEntity="App\Entity\Translations\PerformanceEventTranslation", |
140
|
|
|
* mappedBy="object", |
141
|
|
|
* cascade={"persist", "remove"} |
142
|
|
|
* ) |
143
|
|
|
*/ |
144
|
|
|
protected $translations; |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Unset translations |
148
|
|
|
* |
149
|
|
|
* @return PerformanceEvent |
150
|
|
|
*/ |
151
|
3 |
|
public function unsetTranslations() |
152
|
|
|
{ |
153
|
3 |
|
$this->translations = null; |
154
|
|
|
|
155
|
3 |
|
return $this; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Get id |
160
|
|
|
* |
161
|
|
|
* @return integer |
162
|
|
|
*/ |
163
|
10 |
|
public function getId() |
164
|
|
|
{ |
165
|
10 |
|
return $this->id; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Set dateTime |
170
|
|
|
* |
171
|
|
|
* @param \DateTime $dateTime |
172
|
|
|
* @return PerformanceEvent |
173
|
|
|
*/ |
174
|
1 |
|
public function setDateTime($dateTime) |
175
|
|
|
{ |
176
|
1 |
|
$this->dateTime = $dateTime; |
177
|
|
|
|
178
|
1 |
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Get dateTime |
183
|
|
|
* |
184
|
|
|
* @return \DateTime |
185
|
|
|
*/ |
186
|
15 |
|
public function getDateTime() |
187
|
|
|
{ |
188
|
15 |
|
return $this->dateTime; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Set performance |
193
|
|
|
* |
194
|
|
|
* @param \App\Entity\Performance $performance |
195
|
|
|
* @return PerformanceEvent |
196
|
|
|
*/ |
197
|
1 |
|
public function setPerformance(\App\Entity\Performance $performance = null) |
198
|
|
|
{ |
199
|
1 |
|
$this->performance = $performance; |
200
|
|
|
|
201
|
1 |
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Get performance |
206
|
|
|
* |
207
|
|
|
* @return \App\Entity\Performance |
208
|
|
|
*/ |
209
|
6 |
|
public function getPerformance() |
210
|
|
|
{ |
211
|
6 |
|
return $this->performance; |
212
|
|
|
} |
213
|
|
|
|
214
|
1 |
|
public function __toString() |
215
|
|
|
{ |
216
|
1 |
|
if ($this->getDateTime()) { |
217
|
1 |
|
return $this->getDateTime()->format('d-m-Y H:i'); |
218
|
|
|
} else { |
219
|
|
|
return date("F j, Y, g:i a"); |
220
|
|
|
} |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @return mixed |
225
|
|
|
*/ |
226
|
3 |
|
public function getYear() |
227
|
|
|
{ |
228
|
3 |
|
return $this->getDateTime()->format('Y'); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @param mixed $year |
233
|
|
|
*/ |
234
|
|
|
public function setYear($year) |
235
|
|
|
{ |
236
|
|
|
$this->year = $year; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* @return int |
241
|
|
|
*/ |
242
|
3 |
|
public function getMonth() |
243
|
|
|
{ |
244
|
3 |
|
return $this->getDateTime()->format('n'); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* @param int $month |
249
|
|
|
*/ |
250
|
|
|
public function setMonth($month) |
251
|
|
|
{ |
252
|
|
|
$this->month = $month; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @return int |
257
|
|
|
*/ |
258
|
3 |
|
public function getDay() |
259
|
|
|
{ |
260
|
3 |
|
return $this->getDateTime()->format('j'); |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* @param int $day |
265
|
|
|
*/ |
266
|
|
|
public function setDay($day) |
267
|
|
|
{ |
268
|
|
|
$this->day = $day; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* @return string |
273
|
|
|
*/ |
274
|
3 |
|
public function getTime() |
275
|
|
|
{ |
276
|
3 |
|
return $this->getDateTime()->format('G:i'); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* @param string $time |
281
|
|
|
*/ |
282
|
|
|
public function setTime($time) |
283
|
|
|
{ |
284
|
|
|
$this->time = $time; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @return string |
289
|
|
|
*/ |
290
|
6 |
|
public function getVenue() |
291
|
|
|
{ |
292
|
6 |
|
return $this->venue; |
293
|
|
|
} |
294
|
|
|
|
295
|
4 |
|
public function setVenue(string $venue): self |
296
|
|
|
{ |
297
|
4 |
|
$this->venue = $venue; |
298
|
4 |
|
return $this; |
299
|
|
|
} |
300
|
|
|
|
301
|
3 |
|
public function getBuyTicketLink(): ?string |
302
|
|
|
{ |
303
|
3 |
|
return $this->buyTicketLink; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
public function setBuyTicketLink(?string $buyTicketLink): self |
307
|
|
|
{ |
308
|
|
|
$this->buyTicketLink = $buyTicketLink; |
309
|
|
|
return $this; |
310
|
|
|
} |
311
|
|
|
} |
312
|
|
|
|