Film.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <?php
  2. namespace AppBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * Film
  6. *
  7. * @ORM\Table(name="film")
  8. * @ORM\Entity(repositoryClass="AppBundle\Repository\FilmRepository")
  9. */
  10. class Film
  11. {
  12. /**
  13. * @var int
  14. *
  15. * @ORM\Column(name="id", type="integer")
  16. * @ORM\Id
  17. * @ORM\GeneratedValue(strategy="AUTO")
  18. */
  19. private $id;
  20. /**
  21. * @var string
  22. *
  23. * @ORM\Column(name="titre", type="string", length=255)
  24. */
  25. private $titre;
  26. /**
  27. * @var \DateTime
  28. *
  29. * @ORM\Column(name="annee", type="date", nullable=true)
  30. */
  31. private $annee;
  32. /**
  33. * @var \DateTime
  34. *
  35. * @ORM\Column(name="date_submited", type="datetime", nullable=true)
  36. */
  37. private $dateSubmited;
  38. /**
  39. * @return \DateTime
  40. */
  41. public function getDateSubmited()
  42. {
  43. return $this->dateSubmited;
  44. }
  45. /**
  46. * @param \DateTime $dateSubmited
  47. */
  48. public function setDateSubmited(\DateTime $dateSubmited)
  49. {
  50. $this->dateSubmited = $dateSubmited;
  51. }
  52. /**
  53. * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Realisateur", inversedBy="films", cascade="persist")
  54. * @var \Doctrine\Common\Collections\Collection
  55. */
  56. private $realisateurs;
  57. /**
  58. * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User")
  59. * @ORM\JoinColumn(nullable=true)
  60. */
  61. private $authered;
  62. /**
  63. * @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", inversedBy="films")
  64. * @ORM\JoinTable(name="filmsavoir_users")
  65. * @var \Doctrine\Common\Collections\Collection
  66. */
  67. private $usersWantToView;
  68. /**
  69. * @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", inversedBy="filmsVus")
  70. * @ORM\JoinTable(name="filmsvus_users")
  71. * @var \Doctrine\Common\Collections\Collection
  72. */
  73. private $usersWhoSeen;
  74. /**
  75. * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Genre", cascade={"persist"})
  76. * @var \Doctrine\Common\Collections\Collection
  77. */
  78. private $genres;
  79. /**
  80. * @return mixed
  81. */
  82. public function getAuthered()
  83. {
  84. return $this->authered;
  85. }
  86. /**
  87. * @param mixed $authered
  88. */
  89. public function setAuthered($authered)
  90. {
  91. $this->authered = $authered;
  92. $this->addUserWantToView($authered);
  93. }
  94. /**
  95. * Get id
  96. *
  97. * @return int
  98. */
  99. public function getId()
  100. {
  101. return $this->id;
  102. }
  103. /**
  104. * Set titre
  105. *
  106. * @param string $titre
  107. *
  108. * @return Film
  109. */
  110. public function setTitre($titre)
  111. {
  112. $this->titre = $titre;
  113. return $this;
  114. }
  115. /**
  116. * Get titre
  117. *
  118. * @return string
  119. */
  120. public function getTitre()
  121. {
  122. return $this->titre;
  123. }
  124. /**
  125. * Set annee
  126. *
  127. * @param \DateTime $annee
  128. *
  129. * @return Film
  130. */
  131. public function setAnnee($annee)
  132. {
  133. $this->annee = $annee;
  134. return $this;
  135. }
  136. /**
  137. * Get annee
  138. *
  139. * @return \DateTime
  140. */
  141. public function getAnnee()
  142. {
  143. return $this->annee;
  144. }
  145. /**
  146. * Constructor
  147. */
  148. public function __construct()
  149. {
  150. $this->realisateurs = new \Doctrine\Common\Collections\ArrayCollection();
  151. $this->usersWantToView = new \Doctrine\Common\Collections\ArrayCollection();
  152. $this->usersWhoSeen = new \Doctrine\Common\Collections\ArrayCollection();
  153. $this->genres = new \Doctrine\Common\Collections\ArrayCollection();
  154. $this->setDateSubmited(new \DateTime());
  155. }
  156. /**
  157. * Add realisateur
  158. *
  159. * @param \AppBundle\Entity\Realisateur $realisateur
  160. *
  161. * @return Film
  162. */
  163. public function addRealisateur(\AppBundle\Entity\Realisateur $realisateur)
  164. {
  165. $this->realisateurs[] = $realisateur;
  166. return $this;
  167. }
  168. /**
  169. * Remove realisateur
  170. *
  171. * @param \AppBundle\Entity\Realisateur $realisateur
  172. */
  173. public function removeRealisateur(\AppBundle\Entity\Realisateur $realisateur)
  174. {
  175. $this->realisateurs->removeElement($realisateur);
  176. }
  177. /**
  178. * Get realisateurs
  179. *
  180. * @return \Doctrine\Common\Collections\Collection
  181. */
  182. public function getRealisateurs()
  183. {
  184. return $this->realisateurs;
  185. }
  186. ///////////////////////////////////////////////////////
  187. /**
  188. * Add user
  189. *
  190. * @param \AppBundle\Entity\User $user
  191. *
  192. * @return film
  193. */
  194. public function addUserWantToView(\AppBundle\Entity\User $user)
  195. {
  196. $this->usersWantToView[] = $user;
  197. $user->addFilm($this);
  198. return $this;
  199. }
  200. /**
  201. * Remove user
  202. *
  203. * @param \AppBundle\Entity\User $user
  204. */
  205. public function removeUserWantToView(\AppBundle\Entity\User $user)
  206. {
  207. $this->usersWantToView->removeElement($user);
  208. $user->removeFilm($this);
  209. }
  210. /**
  211. * Get usersWantToView
  212. *
  213. * @return \Doctrine\Common\Collections\Collection
  214. */
  215. public function getUsersWantToView()
  216. {
  217. return $this->usersWantToView;
  218. }
  219. /**
  220. * Inverse ToSee
  221. * @param \AppBundle\Entity\User $user
  222. */
  223. public function inverseUserWantToView(\AppBundle\Entity\User $user)
  224. {
  225. if ($this->usersWantToView->contains($user)) {
  226. $this->removeUserWantToView($user);
  227. } else {
  228. $this->addUserWantToView($user);
  229. }
  230. }
  231. /////////////////////////////////////////////////////////////////////
  232. /**
  233. * Add user
  234. *
  235. * @param \AppBundle\Entity\User $user
  236. *
  237. * @return film
  238. */
  239. public function addUserWhoSeen(\AppBundle\Entity\User $user)
  240. {
  241. $this->usersWhoSeen[] = $user;
  242. $user->addFilmVu($this);
  243. return $this;
  244. }
  245. /**
  246. * Remove user
  247. *
  248. * @param \AppBundle\Entity\User $user
  249. */
  250. public function removeUserWhoSeen(\AppBundle\Entity\User $user)
  251. {
  252. $this->usersWhoSeen->removeElement($user);
  253. $user->removeFilmVu($this);
  254. }
  255. /**
  256. * Get usersWantToView
  257. *
  258. * @return \Doctrine\Common\Collections\Collection
  259. */
  260. public function getUsersWhoSeen()
  261. {
  262. return $this->usersWhoSeen;
  263. }
  264. /**
  265. * Inverse ToSee
  266. * @param \AppBundle\Entity\User $user
  267. */
  268. public function inverseUserWhoSeen(\AppBundle\Entity\User $user)
  269. {
  270. if ($this->usersWhoSeen->contains($user)) {
  271. $this->removeUserWhoSeen($user);
  272. } else {
  273. $this->addUserWhoSeen($user);
  274. }
  275. }
  276. /**
  277. * Get genre
  278. *
  279. * @return \Doctrine\Common\Collections\Collection
  280. */
  281. public function getGenres()
  282. {
  283. return $this->genres;
  284. }
  285. /**
  286. * Add genre
  287. *
  288. * @param \AppBundle\Entity\Genre $genre
  289. *
  290. * @return film
  291. */
  292. public function addGenre(\AppBundle\Entity\Genre $genre)
  293. {
  294. $this->genres[] = $genre;
  295. return $this;
  296. }
  297. /**
  298. * Remove genre
  299. *
  300. * @param \AppBundle\Entity\Genre $genre
  301. * @return Film
  302. */
  303. public function removeGenre(\AppBundle\Entity\Genre $genre)
  304. {
  305. $this->genres->removeElement($genre);
  306. return $this;
  307. }
  308. }