1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use AppBundle\Traits\TimestampableTrait; |
6
|
|
|
use Doctrine\Common\Annotations\Annotation\Enum; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use JMS\Serializer\Annotation as Serializer; |
9
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy; |
10
|
|
|
use JMS\Serializer\Annotation\Expose; |
11
|
|
|
use JMS\Serializer\Annotation\Type; |
12
|
|
|
use Ramsey\Uuid\Uuid; |
13
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @ORM\Table(name="ticket") |
17
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\TicketRepository") |
18
|
|
|
* @ExclusionPolicy("all") |
19
|
|
|
*/ |
20
|
|
|
class Ticket |
21
|
|
|
{ |
22
|
|
|
use TimestampableTrait; |
23
|
|
|
|
24
|
|
|
const STATUS_FREE = 'free'; |
25
|
|
|
const STATUS_BOOKED = 'booked'; |
26
|
|
|
const STATUS_PAID = 'paid'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var Uuid |
30
|
|
|
* |
31
|
|
|
* @ORM\Column(name="id", type="uuid_binary") |
32
|
|
|
* @ORM\Id |
33
|
|
|
* @ORM\GeneratedValue(strategy="UUID") |
34
|
|
|
* |
35
|
|
|
* @Serializer\Groups({"get_ticket", "cget_ticket"}) |
36
|
|
|
* @Type("string") |
37
|
|
|
* @Expose |
38
|
|
|
*/ |
39
|
|
|
private $id; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
* @Assert\NotBlank() |
44
|
|
|
* @ORM\Column(type="string", length=5, nullable=false) |
45
|
|
|
* |
46
|
|
|
* @Serializer\Groups({"get_ticket", "cget_ticket"}) |
47
|
|
|
* @Type("string") |
48
|
|
|
* @Expose |
49
|
|
|
*/ |
50
|
|
|
private $series; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string |
54
|
|
|
* @Assert\NotBlank() |
55
|
|
|
* @ORM\Column(type="string", length=20, nullable=false) |
56
|
|
|
* |
57
|
|
|
* @Serializer\Groups({"get_ticket", "cget_ticket"}) |
58
|
|
|
* @Type("string") |
59
|
|
|
* @Expose |
60
|
|
|
*/ |
61
|
|
|
private $number; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var integer |
65
|
|
|
* @Assert\NotBlank() |
66
|
|
|
* @ORM\Column(type="integer", nullable=false) |
67
|
|
|
* |
68
|
|
|
* @Serializer\Groups({"get_ticket", "cget_ticket"}) |
69
|
|
|
* @Type("integer") |
70
|
|
|
* @Expose |
71
|
|
|
*/ |
72
|
|
|
private $price; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var Seat |
76
|
|
|
* |
77
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Seat", fetch="EAGER") |
78
|
|
|
* @ORM\JoinColumn(name="seat_id", referencedColumnName="id", nullable=false) |
79
|
|
|
* |
80
|
|
|
* @Serializer\Groups({"get_ticket", "cget_ticket"}) |
81
|
|
|
* @Type("AppBundle\Entity\Seat") |
82
|
|
|
* @Expose() |
83
|
|
|
*/ |
84
|
|
|
protected $seat; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var PerformanceEvent |
88
|
|
|
* |
89
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\PerformanceEvent", fetch="EAGER") |
90
|
|
|
* @ORM\JoinColumn(name="performance_event_id", referencedColumnName="id", nullable=false) |
91
|
|
|
* |
92
|
|
|
* @Serializer\Groups({"get_ticket"}) |
93
|
|
|
* @Type("AppBundle\Entity\PerformanceEvent") |
94
|
|
|
* @Expose() |
95
|
|
|
*/ |
96
|
|
|
protected $performanceEvent; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @var CustomerOrder |
100
|
|
|
* |
101
|
|
|
* @ORM\ManyToOne(targetEntity="CustomerOrder", inversedBy="tickets") |
102
|
|
|
*/ |
103
|
|
|
protected $customerOrder; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @var Enum |
107
|
|
|
* @Assert\Choice(callback="getStatuses") |
108
|
|
|
* @ORM\Column(name="status", type="string", columnDefinition="enum('free', 'booked', 'paid')") |
109
|
|
|
* @Serializer\Groups({"get_ticket", "cget_ticket"}) |
110
|
|
|
* @Expose() |
111
|
|
|
*/ |
112
|
|
|
protected $status; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Ticket constructor. |
116
|
|
|
* |
117
|
|
|
* @param Seat $seat |
118
|
|
|
* @param PerformanceEvent $performanceEvent |
119
|
|
|
*/ |
120
|
|
|
public function __construct(Seat $seat, PerformanceEvent $performanceEvent) |
121
|
|
|
{ |
122
|
|
|
$this->id = Uuid::uuid4(); |
123
|
|
|
$this->seat = $seat; |
124
|
|
|
$this->performanceEvent = $performanceEvent; |
125
|
|
|
$this->status = self::STATUS_FREE; |
|
|
|
|
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function getId() |
132
|
|
|
{ |
133
|
|
|
// return $this->id->toString(); |
|
|
|
|
134
|
|
|
return $this->id; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return string |
139
|
|
|
*/ |
140
|
|
|
public function getSeries() |
141
|
|
|
{ |
142
|
|
|
return $this->series; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param string $series |
147
|
|
|
*/ |
148
|
|
|
public function setSeries($series) |
149
|
|
|
{ |
150
|
|
|
$this->series = $series; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return string |
155
|
|
|
*/ |
156
|
|
|
public function getNumber() |
157
|
|
|
{ |
158
|
|
|
return $this->number; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param string $number |
163
|
|
|
*/ |
164
|
|
|
public function setNumber($number) |
165
|
|
|
{ |
166
|
|
|
$this->number = $number; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return int |
171
|
|
|
*/ |
172
|
|
|
public function getPrice() |
173
|
|
|
{ |
174
|
|
|
return $this->price; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param int $price |
179
|
|
|
*/ |
180
|
|
|
public function setPrice($price) |
181
|
|
|
{ |
182
|
|
|
$this->price = $price; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return Seat |
187
|
|
|
*/ |
188
|
|
|
public function getSeat() |
189
|
|
|
{ |
190
|
|
|
return $this->seat; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return PerformanceEvent |
195
|
|
|
*/ |
196
|
|
|
public function getPerformanceEvent() |
197
|
|
|
{ |
198
|
|
|
return $this->performanceEvent; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return Enum |
203
|
|
|
*/ |
204
|
|
|
public function getStatus() |
205
|
|
|
{ |
206
|
|
|
return $this->status; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param Enum $status |
211
|
|
|
*/ |
212
|
|
|
public function setStatus($status) |
213
|
|
|
{ |
214
|
|
|
$this->status = $status; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return array |
219
|
|
|
*/ |
220
|
|
|
public static function getStatuses() |
221
|
|
|
{ |
222
|
|
|
return [ |
223
|
|
|
self::STATUS_FREE, |
224
|
|
|
self::STATUS_BOOKED, |
225
|
|
|
self::STATUS_PAID, |
226
|
|
|
]; |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..