lastActivity; } /** * @param \DateTime $lastActivity */ public function setLastActivity($lastActivity) { $this->lastActivity = $lastActivity; } /** * @return boolean */ public function isActiveNow() { $delay = new \DateTime('2 minutes ago'); return ( $this->getLastActivity() > $delay ); } /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Film", mappedBy="usersWantToView") * @var \Doctrine\Common\Collections\Collection */ private $films; /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Film", mappedBy="usersWhoSeen") * @var \Doctrine\Common\Collections\Collection */ private $filmsVus; /** * Get id * * @return int */ public function getId() { return $this->id; } /** * Set username * * @param string $username * * @return User */ public function setUsername($username) { $this->username = $username; return $this; } /** * Get username * * @return string */ public function getUsername() { return $this->username; } /** * @return string */ public function getPrenom() { return $this->prenom; } /** * @param string $prenom */ public function setPrenom($prenom) { $this->prenom = $prenom; } /** * @return string */ public function getNom() { return $this->nom; } /** * @param string $nom */ public function setNom($nom) { $this->nom = $nom; } /** * @return string */ public function getMail() { return $this->mail; } /** * @param string $mail */ public function setMail($mail) { $this->mail = $mail; } /** * Set password * * @param string $password * * @return User */ public function setPassword($password) { $this->password = $password; return $this; } /** * Get password * * @return string */ public function getPassword() { return $this->password; } /** * Set salt * * @param string $salt * * @return User */ public function setSalt($salt) { $this->salt = $salt; return $this; } /** * Get salt * * @return string */ public function getSalt() { return $this->salt; } /** * Get token * * @return string */ public function getToken() { return $this->token; } /** * Set token * * @return User */ public function setToken() { $this->token = hash("sha512", uniqid()); $this->setTokenValidity(new \DateTime()); return $this; } /** * Get token_validity * * @return \DateTime */ public function getTokenValidity() { return $this->tokenValidity; } /** * Set token * * @param \DateTime $tokenValidity * * @return User */ private function setTokenValidity(\DateTime $tokenValidity) { $this->tokenValidity = $tokenValidity; return $this; } /** * Is ValidToken * * @return boolean * */ public function isValidToken() { $expire = $this->getTokenValidity()->modify('+1 hour'); return ( $expire > new \DateTime('now') ); } /** * Set roles * * @param array $roles * * @return User */ public function setRoles($roles) { $this->roles = $roles; return $this; } /** * Get roles * * @return array */ public function getRoles() { return $this->roles; } public function eraseCredentials() { } /** * Constructor */ public function __construct() { $this->films = new \Doctrine\Common\Collections\ArrayCollection(); $this->setToken(); $this->setLastActivity(new \DateTime('now')); } /////////////////////////////////////////////////////////////// /** * Add film * * @param \AppBundle\Entity\Film $film * * @return User */ public function addFilm(\AppBundle\Entity\Film $film) { $this->films[] = $film; return $this; } /** * Remove film * * @param \AppBundle\Entity\Film $film */ public function removeFilm(\AppBundle\Entity\Film $film) { $this->films->removeElement($film); } /** * Get films * * @return \Doctrine\Common\Collections\Collection */ public function getFilms() { return $this->films; } /////////////////////////////////////////////////////////////////////////// /** * Add film * * @param \AppBundle\Entity\Film $film * * @return User */ public function addFilmVu(\AppBundle\Entity\Film $film) { $this->filmsVus[] = $film; return $this; } /** * Remove film * * @param \AppBundle\Entity\Film $film */ public function removeFilmVu(\AppBundle\Entity\Film $film) { $this->filmsVus->removeElement($film); } /** * Get films * * @return \Doctrine\Common\Collections\Collection */ public function getFilmsVus() { return $this->filmsVus; } /** * Get nomComplet * @return string */ public function getNomComplet() { return $this->getPrenom()." ".$this->getNom(); } }