1 | <?php |
||
30 | class Movie implements TranslatableInterface |
||
31 | { |
||
32 | use TranslatableTrait; |
||
33 | |||
34 | /** |
||
35 | * @ORM\Id() |
||
36 | * @ORM\GeneratedValue() |
||
37 | * @ORM\Column(type="integer") |
||
38 | * @Groups({"list", "view"}) |
||
39 | */ |
||
40 | private $id; |
||
41 | |||
42 | /** |
||
43 | * @var MovieTranslations[]|ArrayCollection |
||
44 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieTranslations", mappedBy="movie", cascade={"persist", "remove"}) |
||
45 | * @Assert\Valid(traverse=true) |
||
46 | * @Groups({"list", "view"}) |
||
47 | */ |
||
48 | private $translations; |
||
49 | |||
50 | /** |
||
51 | * @var Actor[]|ArrayCollection |
||
52 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieActor", mappedBy="movie", cascade={"persist", "remove"}) |
||
53 | * @Assert\Valid(traverse=true) |
||
54 | * @Groups({"view"}) |
||
55 | */ |
||
56 | private $actors; |
||
57 | |||
58 | /** |
||
59 | * @var Genre[]|ArrayCollection |
||
60 | * @ORM\ManyToMany(targetEntity="App\Genres\Entity\Genre") |
||
61 | * @ORM\JoinTable(name="movies_genres", |
||
62 | * joinColumns={@ORM\JoinColumn(name="movie_id", referencedColumnName="id")}, |
||
63 | * inverseJoinColumns={@ORM\JoinColumn(name="genre_id", referencedColumnName="id")} |
||
64 | * ) |
||
65 | * @ORM\JoinColumn(nullable=false) |
||
66 | * @Assert\Valid(traverse=true) |
||
67 | * @Groups({"list", "view"}) |
||
68 | */ |
||
69 | private $genres; |
||
70 | |||
71 | /** |
||
72 | * @Groups({"list", "view"}) |
||
73 | * @ORM\Column(type="string", length=100) |
||
74 | */ |
||
75 | private $originalTitle; |
||
76 | |||
77 | /** |
||
78 | * @Groups({"list", "view"}) |
||
79 | * @ORM\Column(type="string", length=255, nullable=true) |
||
80 | */ |
||
81 | private $originalPosterUrl; |
||
82 | |||
83 | /** |
||
84 | * @ORM\Embedded(class="App\Movies\Entity\MovieTMDB", columnPrefix="tmdb_") |
||
85 | * @Assert\Valid(traverse=true) |
||
86 | * @Groups({"list", "view"}) |
||
87 | */ |
||
88 | private $tmdb; |
||
89 | |||
90 | /** |
||
91 | * @ORM\Column(type="string", length=20, nullable=true) |
||
92 | * @Groups({"view"}) |
||
93 | */ |
||
94 | private $imdbId; |
||
95 | |||
96 | /** |
||
97 | * @Groups({"view"}) |
||
98 | * @ORM\Column(type="integer", nullable=true, options={"default": 0}) |
||
99 | */ |
||
100 | private $runtime; |
||
101 | |||
102 | /** |
||
103 | * @Groups({"view"}) |
||
104 | * @ORM\Column(type="integer", nullable=true, options={"default": 0}) |
||
105 | */ |
||
106 | private $budget; |
||
107 | |||
108 | /** |
||
109 | * @Groups({"list", "view"}) |
||
110 | * @ORM\Column(type="date", nullable=true) |
||
111 | */ |
||
112 | private $releaseDate; |
||
113 | |||
114 | /** |
||
115 | * @var GuestWatchedMovie |
||
116 | * @ORM\OneToOne(targetEntity="App\Guests\Entity\GuestWatchedMovie", mappedBy="movie") |
||
117 | * @Groups({"list", "view"}) |
||
118 | */ |
||
119 | private $guestWatchedMovie; |
||
120 | |||
121 | /** |
||
122 | * @var UserWatchedMovie |
||
123 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserWatchedMovie", mappedBy="movie") |
||
124 | * @Groups({"ROLE_USER"}) |
||
125 | */ |
||
126 | private $userWatchedMovie; |
||
127 | |||
128 | /** |
||
129 | * @Groups({"list", "view"}) |
||
130 | */ |
||
131 | private $isWatched; |
||
132 | |||
133 | /** |
||
134 | * @var MovieRecommendation |
||
135 | * @ORM\OneToOne(targetEntity="App\Movies\Entity\MovieRecommendation", mappedBy="recommendedMovie") |
||
136 | * @Groups({"ROLE_USER"}) |
||
137 | */ |
||
138 | private $userRecommendedMovie; |
||
139 | |||
140 | /** |
||
141 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\SimilarMovie", mappedBy="originalMovie", cascade={"persist", "remove"}) |
||
142 | */ |
||
143 | private $similarMovies; |
||
144 | |||
145 | /** |
||
146 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieRecommendation", mappedBy="originalMovie", cascade={"persist", "remove"}) |
||
147 | */ |
||
148 | private $recommendations; |
||
149 | |||
150 | 3 | public function __construct(MovieDTO $movieDTO, MovieTMDB $tmdb) |
|
166 | |||
167 | 15 | public function getId(): ?int |
|
171 | |||
172 | 3 | public function addGenre(Genre $genre) |
|
178 | |||
179 | public function removeAllGenres() |
||
185 | |||
186 | /** |
||
187 | * @return Genre[]|array |
||
188 | */ |
||
189 | 12 | public function getGenres() |
|
193 | |||
194 | public function addActor(Actor $actor) |
||
201 | |||
202 | /** |
||
203 | * @return Actor[]|array |
||
204 | */ |
||
205 | 2 | public function getActors(): array |
|
206 | { |
||
207 | 2 | $movieActors = $this->actors->toArray(); |
|
208 | |||
209 | return array_map(function (MovieActor $movieActor) { |
||
210 | 1 | return $movieActor->getActor(); |
|
211 | 2 | }, $movieActors); |
|
212 | } |
||
213 | |||
214 | public function addSimilarMovie(self $similarMovie) |
||
221 | |||
222 | public function removeAllSimilarMovies() |
||
228 | |||
229 | /** |
||
230 | * @return Movie[]|array |
||
231 | */ |
||
232 | 7 | public function getSimilarMovies() |
|
236 | |||
237 | /** |
||
238 | * @return Movie[]|array |
||
239 | */ |
||
240 | public function getRecommendations() |
||
244 | |||
245 | 1 | public function addRecommendation(User $user, self $recommendedMovie) |
|
252 | |||
253 | public function removeAllRecommendations() |
||
259 | |||
260 | public function updateTmdb(MovieTMDB $tmdb) |
||
264 | |||
265 | /** |
||
266 | * @param string $imdbId |
||
267 | * |
||
268 | * @return Movie |
||
269 | */ |
||
270 | 4 | public function setImdbId(?string $imdbId) |
|
276 | |||
277 | /** |
||
278 | * @param int $runtime |
||
279 | * |
||
280 | * @return Movie |
||
281 | */ |
||
282 | 4 | public function setRuntime(int $runtime) |
|
288 | |||
289 | /** |
||
290 | * @param int $budget |
||
291 | * |
||
292 | * @return Movie |
||
293 | */ |
||
294 | 4 | public function setBudget(int $budget) |
|
300 | |||
301 | /** |
||
302 | * @param \DateTimeInterface $releaseDate |
||
303 | * |
||
304 | * @return Movie |
||
305 | */ |
||
306 | 4 | public function setReleaseDate(\DateTimeInterface $releaseDate) |
|
312 | |||
313 | /** |
||
314 | * @return string |
||
315 | */ |
||
316 | 12 | public function getOriginalTitle() |
|
320 | |||
321 | /** |
||
322 | * @param string $title |
||
323 | * |
||
324 | * @return $this |
||
325 | */ |
||
326 | public function changeOriginalTitle(string $title) |
||
332 | |||
333 | /** |
||
334 | * @return mixed |
||
335 | */ |
||
336 | 12 | public function getOriginalPosterUrl() |
|
340 | |||
341 | public function setOriginalPosterUrl(string $url) |
||
345 | |||
346 | /** |
||
347 | * @return MovieTMDB |
||
348 | */ |
||
349 | 13 | public function getTmdb() |
|
353 | |||
354 | /** |
||
355 | * @return mixed |
||
356 | */ |
||
357 | 2 | public function getImdbId() |
|
361 | |||
362 | /** |
||
363 | * @return mixed |
||
364 | */ |
||
365 | 2 | public function getRuntime() |
|
369 | |||
370 | /** |
||
371 | * @return mixed |
||
372 | */ |
||
373 | 2 | public function getBudget() |
|
377 | |||
378 | /** |
||
379 | * @return mixed |
||
380 | */ |
||
381 | 12 | public function getReleaseDate() |
|
385 | |||
386 | 3 | public function getUserWatchedMovie() |
|
390 | |||
391 | 12 | public function getGuestWatchedMovie() |
|
395 | |||
396 | 12 | public function isWatched() |
|
402 | |||
403 | 3 | public function getUserRecommendedMovie() |
|
407 | |||
408 | /** |
||
409 | * @param string $originalTitle |
||
410 | */ |
||
411 | 1 | public function setOriginalTitle(string $originalTitle): void |
|
415 | |||
416 | public function __toString() |
||
420 | } |
||
421 |