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