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