1 | <?php |
||
31 | class Movie implements TranslatableInterface |
||
32 | { |
||
33 | use TranslatableTrait; |
||
34 | |||
35 | /** |
||
36 | * @ORM\Id() |
||
37 | * @ORM\GeneratedValue() |
||
38 | * @ORM\Column(type="integer") |
||
39 | * @Groups({"list", "view"}) |
||
40 | */ |
||
41 | private $id; |
||
42 | |||
43 | /** |
||
44 | * @var MovieTranslations[]|ArrayCollection |
||
45 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieTranslations", mappedBy="movie", cascade={"persist", "remove"}) |
||
46 | * @Assert\Valid(traverse=true) |
||
47 | * @Groups({"list", "view"}) |
||
48 | */ |
||
49 | private $translations; |
||
50 | |||
51 | /** |
||
52 | * @var Actor[]|ArrayCollection |
||
53 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieActor", mappedBy="movie", cascade={"persist", "remove"}) |
||
54 | * @Assert\Valid(traverse=true) |
||
55 | * @Groups({"view"}) |
||
56 | */ |
||
57 | private $actors; |
||
58 | |||
59 | /** |
||
60 | * @var Genre[]|ArrayCollection |
||
61 | * @ORM\ManyToMany(targetEntity="App\Genres\Entity\Genre") |
||
62 | * @ORM\JoinTable(name="movies_genres", |
||
63 | * joinColumns={@ORM\JoinColumn(name="movie_id", referencedColumnName="id")}, |
||
64 | * inverseJoinColumns={@ORM\JoinColumn(name="genre_id", referencedColumnName="id")} |
||
65 | * ) |
||
66 | * @ORM\JoinColumn(nullable=false) |
||
67 | * @Assert\Valid(traverse=true) |
||
68 | * @Groups({"list", "view"}) |
||
69 | */ |
||
70 | private $genres; |
||
71 | |||
72 | /** |
||
73 | * @Groups({"list", "view"}) |
||
74 | * @ORM\Column(type="string", length=100) |
||
75 | */ |
||
76 | private $originalTitle; |
||
77 | |||
78 | /** |
||
79 | * @Groups({"list", "view"}) |
||
80 | * @ORM\Column(type="string", length=255, nullable=true) |
||
81 | */ |
||
82 | private $originalPosterUrl; |
||
83 | |||
84 | /** |
||
85 | * @ORM\Embedded(class="App\Movies\Entity\MovieTMDB", columnPrefix="tmdb_") |
||
86 | * @Assert\Valid(traverse=true) |
||
87 | * @Groups({"list", "view"}) |
||
88 | */ |
||
89 | private $tmdb; |
||
90 | |||
91 | /** |
||
92 | * @ORM\Column(type="string", length=20, nullable=true) |
||
93 | * @Groups({"view"}) |
||
94 | */ |
||
95 | private $imdbId; |
||
96 | |||
97 | /** |
||
98 | * @Groups({"view"}) |
||
99 | * @ORM\Column(type="integer", nullable=true, options={"default": 0}) |
||
100 | */ |
||
101 | private $runtime; |
||
102 | |||
103 | /** |
||
104 | * @Groups({"view"}) |
||
105 | * @ORM\Column(type="integer", nullable=true, options={"default": 0}) |
||
106 | */ |
||
107 | private $budget; |
||
108 | |||
109 | /** |
||
110 | * @Groups({"list", "view"}) |
||
111 | * @ORM\Column(type="date", nullable=true) |
||
112 | */ |
||
113 | private $releaseDate; |
||
114 | |||
115 | /** |
||
116 | * @var GuestWatchedMovie |
||
117 | * @ORM\OneToOne(targetEntity="App\Guests\Entity\GuestWatchedMovie", mappedBy="movie") |
||
118 | * @Groups({"list", "view"}) |
||
119 | */ |
||
120 | private $guestWatchedMovie; |
||
121 | |||
122 | /** |
||
123 | * @var UserWatchedMovie |
||
124 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserWatchedMovie", mappedBy="movie") |
||
125 | * @Groups({"ROLE_USER"}) |
||
126 | */ |
||
127 | private $userWatchedMovie; |
||
128 | |||
129 | /** |
||
130 | * @var UserWatchedMovie |
||
131 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserWatchedMovie", mappedBy="movie") |
||
132 | * @Groups({"userWatchedMovies"}) |
||
133 | */ |
||
134 | private $ownerWatchedMovie; |
||
135 | |||
136 | /** |
||
137 | * @var UserInterestedMovie |
||
138 | * @ORM\OneToOne(targetEntity="App\Users\Entity\UserInterestedMovie", mappedBy="movie") |
||
139 | * @Groups({"ROLE_USER"}) |
||
140 | */ |
||
141 | private $userInterestedMovie; |
||
142 | |||
143 | /** |
||
144 | * @Groups({"list", "view"}) |
||
145 | */ |
||
146 | private $isWatched; |
||
147 | |||
148 | /** |
||
149 | * @var MovieRecommendation |
||
150 | * @ORM\OneToOne(targetEntity="App\Movies\Entity\MovieRecommendation", mappedBy="recommendedMovie") |
||
151 | * @Groups({"ROLE_USER"}) |
||
152 | */ |
||
153 | private $userRecommendedMovie; |
||
154 | |||
155 | /** |
||
156 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\SimilarMovie", mappedBy="originalMovie", cascade={"persist", "remove"}) |
||
157 | */ |
||
158 | private $similarMovies; |
||
159 | |||
160 | /** |
||
161 | * @ORM\OneToMany(targetEntity="App\Movies\Entity\MovieRecommendation", mappedBy="originalMovie", cascade={"persist", "remove"}) |
||
162 | */ |
||
163 | private $recommendations; |
||
164 | |||
165 | 3 | public function __construct(MovieDTO $movieDTO, MovieTMDB $tmdb) |
|
181 | |||
182 | 23 | public function getId(): ?int |
|
186 | |||
187 | 3 | public function addGenre(Genre $genre) |
|
193 | |||
194 | public function removeAllGenres() |
||
200 | |||
201 | /** |
||
202 | * @return Genre[]|array |
||
203 | */ |
||
204 | 13 | public function getGenres() |
|
208 | |||
209 | public function addActor(Actor $actor) |
||
216 | |||
217 | /** |
||
218 | * todo return MovieActor[] because sometimes we need to remove entities like this. |
||
219 | * |
||
220 | * @return Actor[]|array |
||
221 | */ |
||
222 | 3 | public function getActors(): array |
|
230 | |||
231 | public function addSimilarMovie(self $similarMovie) |
||
238 | |||
239 | public function removeAllSimilarMovies() |
||
245 | |||
246 | /** |
||
247 | * @return SimilarMovie[]|array |
||
248 | */ |
||
249 | 10 | public function getSimilarMovies() |
|
253 | |||
254 | /** |
||
255 | * @return MovieRecommendation[]|array |
||
256 | */ |
||
257 | public function getRecommendations() |
||
261 | |||
262 | 6 | public function addRecommendation(User $user, self $recommendedMovie) |
|
269 | |||
270 | public function removeAllRecommendations() |
||
276 | |||
277 | public function updateTmdb(MovieTMDB $tmdb) |
||
281 | |||
282 | /** |
||
283 | * @param string $imdbId |
||
284 | * |
||
285 | * @return Movie |
||
286 | */ |
||
287 | 4 | public function setImdbId(?string $imdbId) |
|
293 | |||
294 | /** |
||
295 | * @param int $runtime |
||
296 | * |
||
297 | * @return Movie |
||
298 | */ |
||
299 | 4 | public function setRuntime(int $runtime) |
|
305 | |||
306 | /** |
||
307 | * @param int $budget |
||
308 | * |
||
309 | * @return Movie |
||
310 | */ |
||
311 | 4 | public function setBudget(int $budget) |
|
317 | |||
318 | /** |
||
319 | * @param \DateTimeInterface $releaseDate |
||
320 | * |
||
321 | * @return Movie |
||
322 | */ |
||
323 | 4 | public function setReleaseDate(?\DateTimeInterface $releaseDate = null) |
|
329 | |||
330 | /** |
||
331 | * @return string |
||
332 | */ |
||
333 | 13 | public function getOriginalTitle() |
|
337 | |||
338 | /** |
||
339 | * @param string $title |
||
340 | * |
||
341 | * @return $this |
||
342 | */ |
||
343 | public function changeOriginalTitle(string $title) |
||
349 | |||
350 | /** |
||
351 | * @return mixed |
||
352 | */ |
||
353 | 13 | public function getOriginalPosterUrl() |
|
357 | |||
358 | 1 | public function setOriginalPosterUrl(string $url) |
|
362 | |||
363 | /** |
||
364 | * @return MovieTMDB |
||
365 | */ |
||
366 | 14 | public function getTmdb() |
|
370 | |||
371 | /** |
||
372 | * @return mixed |
||
373 | */ |
||
374 | 3 | public function getImdbId() |
|
378 | |||
379 | /** |
||
380 | * @return mixed |
||
381 | */ |
||
382 | 3 | public function getRuntime() |
|
386 | |||
387 | /** |
||
388 | * @return mixed |
||
389 | */ |
||
390 | 3 | public function getBudget() |
|
394 | |||
395 | 13 | public function getReleaseDate(): ?\DateTimeInterface |
|
399 | |||
400 | 6 | public function getUserWatchedMovie() |
|
404 | |||
405 | public function getOwnerWatchedMovie() |
||
409 | |||
410 | 13 | public function getGuestWatchedMovie() |
|
414 | |||
415 | 13 | public function isWatched() |
|
421 | |||
422 | 6 | public function getUserInterestedMovie() |
|
426 | |||
427 | 6 | public function getUserRecommendedMovie() |
|
431 | |||
432 | /** |
||
433 | * @param string $originalTitle |
||
434 | */ |
||
435 | 1 | public function setOriginalTitle(string $originalTitle): void |
|
439 | |||
440 | public function __toString() |
||
444 | } |
||
445 |