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