1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace KI\PonthubBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use JMS\Serializer\Annotation as JMS; |
7
|
|
|
use KI\PonthubBundle\Entity\PonthubFile; |
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @ORM\Entity |
12
|
|
|
* @JMS\ExclusionPolicy("all") |
13
|
|
|
*/ |
14
|
|
|
class Movie extends PonthubFile |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Durée (en secondes) |
18
|
|
|
* @ORM\Column(name="duration", type="integer", nullable=true) |
19
|
|
|
* @JMS\Expose |
20
|
|
|
* @Assert\Range(min = 0, max = 86400) |
21
|
|
|
*/ |
22
|
|
|
protected $duration; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Année |
26
|
|
|
* @ORM\Column(name="year", type="integer", nullable=true) |
27
|
|
|
* @JMS\Expose |
28
|
|
|
* @Assert\Range(min = 1000, max = 2050) |
29
|
|
|
*/ |
30
|
|
|
protected $year; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Réalisateur |
34
|
|
|
* @ORM\Column(name="director", type="string", nullable=true) |
35
|
|
|
* @JMS\Expose |
36
|
|
|
* @Assert\Type("string") |
37
|
|
|
*/ |
38
|
|
|
protected $director; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Acteurs |
42
|
|
|
* @ORM\ManyToMany(targetEntity="KI\PonthubBundle\Entity\Actor", cascade={"persist"}) |
43
|
|
|
* @Assert\Valid() |
44
|
|
|
*/ |
45
|
|
|
protected $actors; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @JMS\VirtualProperty() |
49
|
|
|
*/ |
50
|
|
|
public function actorsList() |
51
|
|
|
{ |
52
|
|
|
$actors = []; |
53
|
|
|
foreach ($this->actors as $actor) { |
54
|
|
|
$actors[] = $actor->getName(); |
55
|
|
|
} |
56
|
|
|
return $actors; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Score Metascore/Imdb (en %) |
61
|
|
|
* @ORM\Column(name="rating", type="integer", nullable=true) |
62
|
|
|
* @JMS\Expose |
63
|
|
|
* @Assert\Range(min = 0, max = 100) |
64
|
|
|
*/ |
65
|
|
|
protected $rating; |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
|
69
|
|
|
|
70
|
|
|
|
71
|
|
|
|
72
|
|
|
|
73
|
|
|
//===== GENERATED AUTOMATICALLY =====// |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Constructor |
77
|
|
|
*/ |
78
|
|
|
public function __construct() |
79
|
|
|
{ |
80
|
|
|
parent::__construct(); |
81
|
|
|
$this->actors = new \Doctrine\Common\Collections\ArrayCollection(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Set duration |
86
|
|
|
* |
87
|
|
|
* @param integer $duration |
88
|
|
|
* @return Movie |
89
|
|
|
*/ |
90
|
|
|
public function setDuration($duration) |
91
|
|
|
{ |
92
|
|
|
$this->duration = $duration; |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Get duration |
99
|
|
|
* |
100
|
|
|
* @return integer |
101
|
|
|
*/ |
102
|
|
|
public function getDuration() |
103
|
|
|
{ |
104
|
|
|
return $this->duration; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Set year |
109
|
|
|
* |
110
|
|
|
* @param integer $year |
111
|
|
|
* @return Movie |
112
|
|
|
*/ |
113
|
|
|
public function setYear($year) |
114
|
|
|
{ |
115
|
|
|
$this->year = $year; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get year |
122
|
|
|
* |
123
|
|
|
* @return integer |
124
|
|
|
*/ |
125
|
|
|
public function getYear() |
126
|
|
|
{ |
127
|
|
|
return $this->year; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Set director |
132
|
|
|
* |
133
|
|
|
* @param string $director |
134
|
|
|
* @return Movie |
135
|
|
|
*/ |
136
|
|
|
public function setDirector($director) |
137
|
|
|
{ |
138
|
|
|
$this->director = $director; |
139
|
|
|
|
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Get director |
145
|
|
|
* |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
public function getDirector() |
149
|
|
|
{ |
150
|
|
|
return $this->director; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Set actors |
155
|
|
|
* |
156
|
|
|
* @param array $actors |
157
|
|
|
* @return Movie |
158
|
|
|
*/ |
159
|
|
|
public function setActors($actors) |
160
|
|
|
{ |
161
|
|
|
$this->actors = $actors; |
162
|
|
|
|
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Get actors |
168
|
|
|
* |
169
|
|
|
* @return array |
170
|
|
|
*/ |
171
|
|
|
public function getActors() |
172
|
|
|
{ |
173
|
|
|
return $this->actors; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Add actor |
178
|
|
|
* |
179
|
|
|
* @param \KI\PonthubBundle\Entity\Actor $actor |
180
|
|
|
* @return Movie |
181
|
|
|
*/ |
182
|
|
|
public function addActor(\KI\PonthubBundle\Entity\Actor $actor) |
183
|
|
|
{ |
184
|
|
|
$this->actors[] = $actor; |
185
|
|
|
|
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Remove actor |
191
|
|
|
* |
192
|
|
|
* @param \KI\PonthubBundle\Entity\Actor $actor |
193
|
|
|
*/ |
194
|
|
|
public function removeActor(\KI\PonthubBundle\Entity\Actor $actor) |
195
|
|
|
{ |
196
|
|
|
$this->actors->removeElement($actor); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Set rating |
201
|
|
|
* |
202
|
|
|
* @param string $rating |
203
|
|
|
* @return Movie |
204
|
|
|
*/ |
205
|
|
|
public function setRating($rating) |
206
|
|
|
{ |
207
|
|
|
$this->rating = $rating; |
208
|
|
|
|
209
|
|
|
return $this; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Get rating |
214
|
|
|
* |
215
|
|
|
* @return integer |
216
|
|
|
*/ |
217
|
|
|
public function getRating() |
218
|
|
|
{ |
219
|
|
|
return $this->rating; |
220
|
|
|
} |
221
|
|
|
} |
222
|
|
|
|