1 | <?php |
||
29 | class Movie implements TranslatableInterface |
||
30 | { |
||
31 | use TranslatableTrait; |
||
32 | |||
33 | /** |
||
34 | * @ORM\Id() |
||
35 | * @ORM\GeneratedValue() |
||
36 | * @ORM\Column(type="integer") |
||
37 | * @Groups({"list", "view"}) |
||
38 | */ |
||
39 | private $id; |
||
40 | |||
41 | /** |
||
42 | * @var MovieTranslations[]|ArrayCollection |
||
43 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieTranslations", mappedBy="movie", cascade={"persist", "remove"}) |
||
44 | * @Assert\Valid(traverse=true) |
||
45 | * @Groups({"list", "view"}) |
||
46 | */ |
||
47 | private $translations; |
||
48 | |||
49 | /** |
||
50 | * @var Actor[]|ArrayCollection |
||
51 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieActor", mappedBy="movie", cascade={"persist", "remove"}) |
||
52 | * @Assert\Valid(traverse=true) |
||
53 | * @Groups({"view"}) |
||
54 | */ |
||
55 | private $actors; |
||
56 | |||
57 | /** |
||
58 | * @var Genre[]|ArrayCollection |
||
59 | * @ORM\ManyToMany(targetEntity="App\Genres\Entity\Genre") |
||
60 | * @ORM\JoinTable(name="movies_genres", |
||
61 | * joinColumns={@ORM\JoinColumn(name="movie_id", referencedColumnName="id")}, |
||
62 | * inverseJoinColumns={@ORM\JoinColumn(name="genre_id", referencedColumnName="id")} |
||
63 | * ) |
||
64 | * @ORM\JoinColumn(nullable=false) |
||
65 | * @Assert\Valid(traverse=true) |
||
66 | * @Groups({"list", "view"}) |
||
67 | */ |
||
68 | private $genres; |
||
69 | |||
70 | /** |
||
71 | * @Groups({"list", "view"}) |
||
72 | * @ORM\Column(type="string", length=100) |
||
73 | */ |
||
74 | private $originalTitle; |
||
75 | |||
76 | /** |
||
77 | * @Groups({"list", "view"}) |
||
78 | * @ORM\Column(type="string", length=255, nullable=true) |
||
79 | */ |
||
80 | private $originalPosterUrl; |
||
81 | |||
82 | /** |
||
83 | * @ORM\Embedded(class="App\Movies\Entity\MovieTMDB", columnPrefix="tmdb_") |
||
84 | * @Assert\Valid(traverse=true) |
||
85 | * @Groups({"list", "view"}) |
||
86 | */ |
||
87 | private $tmdb; |
||
88 | |||
89 | /** |
||
90 | * @ORM\Column(type="string", length=20, nullable=true) |
||
91 | * @Groups({"view"}) |
||
92 | */ |
||
93 | private $imdbId; |
||
94 | |||
95 | /** |
||
96 | * @Groups({"view"}) |
||
97 | * @ORM\Column(type="integer", nullable=true, options={"default": 0}) |
||
98 | */ |
||
99 | private $runtime; |
||
100 | |||
101 | /** |
||
102 | * @Groups({"view"}) |
||
103 | * @ORM\Column(type="integer", nullable=true, options={"default": 0}) |
||
104 | */ |
||
105 | private $budget; |
||
106 | |||
107 | /** |
||
108 | * @Groups({"list", "view"}) |
||
109 | * @ORM\Column(type="date", nullable=true) |
||
110 | */ |
||
111 | private $releaseDate; |
||
112 | |||
113 | /** |
||
114 | * @var GuestWatchedMovie |
||
115 | * @ORM\OneToOne(targetEntity="App\Guests\Entity\GuestWatchedMovie", mappedBy="movie") |
||
116 | * @Groups({"list", "view"}) |
||
117 | */ |
||
118 | private $guestWatchedMovie; |
||
119 | |||
120 | /** |
||
121 | * @var UserWatchedMovie |
||
122 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserWatchedMovie", mappedBy="movie") |
||
123 | * @Groups({"ROLE_USER"}) |
||
124 | */ |
||
125 | private $userWatchedMovie; |
||
126 | |||
127 | /** |
||
128 | * @var UserWatchedMovie |
||
129 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserWatchedMovie", mappedBy="movie") |
||
130 | * @Groups({"userWatchedMovies"}) |
||
131 | */ |
||
132 | private $ownerWatchedMovie; |
||
133 | |||
134 | /** |
||
135 | * @var UserInterestedMovie |
||
136 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserInterestedMovie", mappedBy="movie") |
||
137 | * @Groups({"ROLE_USER"}) |
||
138 | */ |
||
139 | private $userInterestedMovie; |
||
140 | |||
141 | /** |
||
142 | * @Groups({"list", "view"}) |
||
143 | */ |
||
144 | private $isWatched; |
||
145 | |||
146 | /** |
||
147 | * @var MovieRecommendation |
||
148 | * @ORM\OneToOne(targetEntity="App\Movies\Entity\MovieRecommendation", mappedBy="recommendedMovie") |
||
149 | * @Groups({"ROLE_USER"}) |
||
150 | */ |
||
151 | private $userRecommendedMovie; |
||
152 | |||
153 | /** |
||
154 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\SimilarMovie", mappedBy="originalMovie", cascade={"persist", "remove"}) |
||
155 | */ |
||
156 | private $similarMovies; |
||
157 | |||
158 | /** |
||
159 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieRecommendation", mappedBy="originalMovie", cascade={"persist", "remove"}) |
||
160 | */ |
||
161 | private $recommendations; |
||
162 | |||
163 | /** |
||
164 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieCard", mappedBy="movie", cascade={"persist", "remove"}) |
||
165 | * @Groups({"view"}) |
||
166 | */ |
||
167 | private $cards; |
||
168 | |||
169 | 3 | public function __construct(MovieDTO $movieDTO, MovieTMDB $tmdb) |
|
186 | |||
187 | 24 | public function getId(): ?int |
|
191 | |||
192 | 3 | public function addGenre(Genre $genre) |
|
198 | |||
199 | public function removeAllGenres() |
||
205 | |||
206 | /** |
||
207 | * @return Genre[]|array |
||
208 | */ |
||
209 | 14 | public function getGenres() |
|
213 | |||
214 | public function addActor(Actor $actor) |
||
221 | |||
222 | /** |
||
223 | * todo return MovieActor[] because sometimes we need to remove entities like this. |
||
224 | * |
||
225 | * @return Actor[]|array |
||
226 | */ |
||
227 | 4 | public function getActors(): array |
|
235 | |||
236 | public function addSimilarMovie(Movie $similarMovie) |
||
243 | |||
244 | public function removeAllSimilarMovies() |
||
250 | |||
251 | /** |
||
252 | * @return SimilarMovie[]|array |
||
253 | */ |
||
254 | 11 | public function getSimilarMovies() |
|
258 | |||
259 | /** |
||
260 | * @return MovieRecommendation[]|array |
||
261 | */ |
||
262 | public function getRecommendations() |
||
266 | |||
267 | 6 | public function addRecommendation(User $user, self $recommendedMovie) |
|
274 | |||
275 | public function removeAllRecommendations() |
||
281 | |||
282 | public function updateTmdb(MovieTMDB $tmdb) |
||
286 | |||
287 | /** |
||
288 | * @param string $imdbId |
||
289 | * |
||
290 | * @return Movie |
||
291 | */ |
||
292 | 4 | public function setImdbId(?string $imdbId) |
|
298 | |||
299 | /** |
||
300 | * @param int $runtime |
||
301 | * |
||
302 | * @return Movie |
||
303 | */ |
||
304 | 4 | public function setRuntime(int $runtime) |
|
310 | |||
311 | /** |
||
312 | * @param int $budget |
||
313 | * |
||
314 | * @return Movie |
||
315 | */ |
||
316 | 4 | public function setBudget(int $budget) |
|
322 | |||
323 | /** |
||
324 | * @param \DateTimeInterface $releaseDate |
||
325 | * |
||
326 | * @return Movie |
||
327 | */ |
||
328 | 4 | public function setReleaseDate(?\DateTimeInterface $releaseDate = null) |
|
334 | |||
335 | /** |
||
336 | * @return string |
||
337 | */ |
||
338 | 14 | public function getOriginalTitle() |
|
342 | |||
343 | /** |
||
344 | * @param string $title |
||
345 | * |
||
346 | * @return $this |
||
347 | */ |
||
348 | public function changeOriginalTitle(string $title) |
||
354 | |||
355 | /** |
||
356 | * @return mixed |
||
357 | */ |
||
358 | 14 | public function getOriginalPosterUrl() |
|
362 | |||
363 | 1 | public function setOriginalPosterUrl(string $url) |
|
367 | |||
368 | /** |
||
369 | * @return MovieTMDB |
||
370 | */ |
||
371 | 15 | public function getTmdb() |
|
375 | |||
376 | /** |
||
377 | * @return mixed |
||
378 | */ |
||
379 | 4 | public function getImdbId() |
|
383 | |||
384 | /** |
||
385 | * @return mixed |
||
386 | */ |
||
387 | 4 | public function getRuntime() |
|
391 | |||
392 | /** |
||
393 | * @return mixed |
||
394 | */ |
||
395 | 4 | public function getBudget() |
|
399 | |||
400 | 14 | public function getReleaseDate(): ?\DateTimeInterface |
|
404 | |||
405 | 7 | public function getUserWatchedMovie() |
|
409 | |||
410 | public function getOwnerWatchedMovie() |
||
414 | |||
415 | 14 | public function getGuestWatchedMovie() |
|
419 | |||
420 | 14 | public function isWatched() |
|
426 | |||
427 | 7 | public function getUserInterestedMovie() |
|
431 | |||
432 | 7 | public function getUserRecommendedMovie() |
|
436 | |||
437 | /** |
||
438 | * @param string $originalTitle |
||
439 | */ |
||
440 | 1 | public function setOriginalTitle(string $originalTitle): void |
|
444 | |||
445 | /** |
||
446 | * @return ArrayCollection|MovieCard[] |
||
447 | */ |
||
448 | 4 | public function getCards() |
|
452 | |||
453 | public function __toString() |
||
457 | } |
||
458 |