Film.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. /**
  6. * Film
  7. *
  8. * @ORM\Table(name="film")
  9. * @ORM\Entity(repositoryClass="App\Repository\FilmRepository")
  10. */
  11. class Film
  12. {
  13. /**
  14. * @var int
  15. *
  16. * @ORM\Column(name="id", type="integer")
  17. * @ORM\Id
  18. * @ORM\GeneratedValue(strategy="AUTO")
  19. */
  20. private $id;
  21. /**
  22. * @var string
  23. *
  24. * @ORM\Column(name="titre", type="string", length=191)
  25. */
  26. private $titre;
  27. /**
  28. * @var \DateTime
  29. *
  30. * @ORM\Column(name="annee", type="date", nullable=true)
  31. */
  32. private $annee;
  33. /**
  34. * @var \DateTime
  35. *
  36. * @ORM\Column(name="date_submited", type="datetime", nullable=true)
  37. */
  38. private $dateSubmited;
  39. /**
  40. * @var string
  41. *
  42. * @ORM\Column(name="lien", type="string", length=191, nullable=true)
  43. * @Assert\Url()
  44. */
  45. private $lien;
  46. /**
  47. * @var float
  48. *
  49. * @ORM\Column(name="note", type="float", nullable=true)
  50. */
  51. private $note;
  52. /**
  53. * @var int
  54. *
  55. * @ORM\Column(name="nb_coms", type="integer", nullable=true)
  56. */
  57. private $nbComs;
  58. /**
  59. * @return \DateTime
  60. */
  61. public function getDateSubmited()
  62. {
  63. return $this->dateSubmited;
  64. }
  65. /**
  66. * @param \DateTime $dateSubmited
  67. */
  68. public function setDateSubmited(\DateTime $dateSubmited)
  69. {
  70. $this->dateSubmited = $dateSubmited;
  71. }
  72. /**
  73. * @return boolean
  74. */
  75. public function isNew()
  76. {
  77. $finNew = $this->getDateSubmited()->modify('+1 day');
  78. return (new \DateTime('now') < $finNew);
  79. }
  80. /**
  81. * @Assert\Valid()
  82. * @ORM\OneToOne(targetEntity="App\Entity\MediaVideo", cascade={"persist","remove"})
  83. * @ORM\JoinColumn(nullable=true)
  84. */
  85. private $mediaVideo;
  86. /**
  87. * @ORM\ManyToMany(targetEntity="App\Entity\Realisateur", inversedBy="films", cascade="persist")
  88. * @var \Doctrine\Common\Collections\Collection
  89. */
  90. private $realisateurs;
  91. /**
  92. * @ORM\ManyToOne(targetEntity="App\Entity\User")
  93. * @ORM\JoinColumn(nullable=true)
  94. */
  95. private $authered;
  96. /**
  97. * @ORM\ManyToMany(targetEntity="App\Entity\User", inversedBy="films")
  98. * @ORM\JoinTable(name="filmsavoir_users")
  99. * @var \Doctrine\Common\Collections\Collection
  100. */
  101. private $usersWantToView;
  102. /**
  103. * @ORM\ManyToMany(targetEntity="App\Entity\User", inversedBy="filmsVus")
  104. * @ORM\JoinTable(name="filmsvus_users")
  105. * @var \Doctrine\Common\Collections\Collection
  106. */
  107. private $usersWhoSeen;
  108. /**
  109. * @return \App\Entity\MediaVideo $mediaVideo
  110. */
  111. public function getMediaVideo()
  112. {
  113. return $this->mediaVideo;
  114. }
  115. /**
  116. * @param \App\Entity\MediaVideo $mediaVideo
  117. */
  118. public function setMediaVideo(MediaVideo $mediaVideo = null)
  119. {
  120. $this->mediaVideo = $mediaVideo;
  121. }
  122. /**
  123. * @ORM\ManyToMany(targetEntity="App\Entity\Genre", cascade={"persist"})
  124. * @var \Doctrine\Common\Collections\Collection
  125. */
  126. private $genres;
  127. /**
  128. * @return \App\Entity\User $authered
  129. */
  130. public function getAuthered()
  131. {
  132. return $this->authered;
  133. }
  134. /**
  135. * @param \App\Entity\User $authered
  136. */
  137. public function setAuthered(User $authered)
  138. {
  139. $this->authered = $authered;
  140. }
  141. /**
  142. * Get id
  143. *
  144. * @return int
  145. */
  146. public function getId()
  147. {
  148. return $this->id;
  149. }
  150. /**
  151. * Set titre
  152. *
  153. * @param string $titre
  154. *
  155. * @return Film
  156. */
  157. public function setTitre($titre)
  158. {
  159. $this->titre = $titre;
  160. return $this;
  161. }
  162. /**
  163. * Get titre
  164. *
  165. * @return string
  166. */
  167. public function getTitre()
  168. {
  169. return $this->titre;
  170. }
  171. /**
  172. * Set annee
  173. *
  174. * @param \DateTime $annee
  175. *
  176. * @return Film
  177. */
  178. public function setAnnee($annee)
  179. {
  180. $this->annee = $annee;
  181. return $this;
  182. }
  183. /**
  184. * Get annee
  185. *
  186. * @return \DateTime
  187. */
  188. public function getAnnee()
  189. {
  190. return $this->annee;
  191. }
  192. /**
  193. * @return string
  194. */
  195. public function getLien()
  196. {
  197. return $this->lien;
  198. }
  199. /**
  200. * @param string $lien
  201. */
  202. public function setLien($lien = null)
  203. {
  204. $this->lien = $lien;
  205. }
  206. /**
  207. * Constructor
  208. */
  209. public function __construct()
  210. {
  211. $this->realisateurs = new \Doctrine\Common\Collections\ArrayCollection();
  212. $this->usersWantToView = new \Doctrine\Common\Collections\ArrayCollection();
  213. $this->usersWhoSeen = new \Doctrine\Common\Collections\ArrayCollection();
  214. $this->genres = new \Doctrine\Common\Collections\ArrayCollection();
  215. $this->setDateSubmited(new \DateTime());
  216. }
  217. /**
  218. * Add realisateur
  219. *
  220. * @param \App\Entity\Realisateur $realisateur
  221. *
  222. * @return Film
  223. */
  224. public function addRealisateur(Realisateur $realisateur)
  225. {
  226. $this->realisateurs[] = $realisateur;
  227. return $this;
  228. }
  229. /**
  230. * Remove realisateur
  231. *
  232. * @param \App\Entity\Realisateur $realisateur
  233. */
  234. public function removeRealisateur(Realisateur $realisateur)
  235. {
  236. $this->realisateurs->removeElement($realisateur);
  237. }
  238. /**
  239. * Get realisateurs
  240. *
  241. * @return \Doctrine\Common\Collections\Collection
  242. */
  243. public function getRealisateurs()
  244. {
  245. return $this->realisateurs;
  246. }
  247. ///////////////////////////////////////////////////////
  248. /**
  249. * Add user
  250. *
  251. * @param \App\Entity\User $user
  252. *
  253. * @return film
  254. */
  255. public function addUserWantToView(User $user)
  256. {
  257. $this->usersWantToView[] = $user;
  258. $user->addFilm($this);
  259. return $this;
  260. }
  261. /**
  262. * Remove user
  263. *
  264. * @param \App\Entity\User $user
  265. */
  266. public function removeUserWantToView(User $user)
  267. {
  268. $this->usersWantToView->removeElement($user);
  269. $user->removeFilm($this);
  270. }
  271. /**
  272. * Get usersWantToView
  273. *
  274. * @return \Doctrine\Common\Collections\Collection
  275. */
  276. public function getUsersWantToView()
  277. {
  278. return $this->usersWantToView;
  279. }
  280. /**
  281. * Inverse ToSee
  282. * @param \App\Entity\User $user
  283. */
  284. public function inverseUserWantToView(User $user)
  285. {
  286. if ($this->usersWantToView->contains($user)) {
  287. $this->removeUserWantToView($user);
  288. } else {
  289. $this->addUserWantToView($user);
  290. }
  291. }
  292. /////////////////////////////////////////////////////////////////////
  293. /**
  294. * Add user
  295. *
  296. * @param \App\Entity\User $user
  297. *
  298. * @return film
  299. */
  300. public function addUserWhoSeen(User $user)
  301. {
  302. $this->usersWhoSeen[] = $user;
  303. $user->addFilmVu($this);
  304. return $this;
  305. }
  306. /**
  307. * Remove user
  308. *
  309. * @param \App\Entity\User $user
  310. */
  311. public function removeUserWhoSeen(User $user)
  312. {
  313. $this->usersWhoSeen->removeElement($user);
  314. $user->removeFilmVu($this);
  315. }
  316. /**
  317. * Get usersWantToView
  318. *
  319. * @return \Doctrine\Common\Collections\Collection
  320. */
  321. public function getUsersWhoSeen()
  322. {
  323. return $this->usersWhoSeen;
  324. }
  325. /**
  326. * Inverse ToSee
  327. * @param \App\Entity\User $user
  328. */
  329. public function inverseUserWhoSeen(User $user)
  330. {
  331. if ($this->usersWhoSeen->contains($user)) {
  332. $this->removeUserWhoSeen($user);
  333. } else {
  334. $this->addUserWhoSeen($user);
  335. }
  336. }
  337. /**
  338. * Get genre
  339. *
  340. * @return \Doctrine\Common\Collections\Collection
  341. */
  342. public function getGenres()
  343. {
  344. return $this->genres;
  345. }
  346. /**
  347. * Add genre
  348. *
  349. * @param \App\Entity\Genre $genre
  350. *
  351. * @return film
  352. */
  353. public function addGenre(Genre $genre)
  354. {
  355. $this->genres[] = $genre;
  356. return $this;
  357. }
  358. /**
  359. * Remove genre
  360. *
  361. * @param \App\Entity\Genre $genre
  362. * @return Film
  363. */
  364. public function removeGenre(Genre $genre)
  365. {
  366. $this->genres->removeElement($genre);
  367. return $this;
  368. }
  369. /**
  370. * @return float
  371. */
  372. public function getNote()
  373. {
  374. return $this->note;
  375. }
  376. /**
  377. * @param float $note
  378. */
  379. public function setNote($note)
  380. {
  381. $this->note = $note;
  382. }
  383. /**
  384. * @return int
  385. */
  386. public function getNbComs()
  387. {
  388. return $this->nbComs;
  389. }
  390. /**
  391. * @param int $nbComs
  392. */
  393. public function setNbComs($nbComs)
  394. {
  395. $this->nbComs = $nbComs;
  396. }
  397. }