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