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