|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Entity;
|
|
|
|
|
|
use App\Repository\UserRepository;
|
|
|
+use Doctrine\Common\Collections\Collection;
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
@@ -69,86 +70,96 @@ class User implements UserInterface,PasswordAuthenticatedUserInterface
|
|
|
#[Assert\Type("DateTime")]
|
|
|
private $lastActivity;
|
|
|
|
|
|
- public function getLastActivity()
|
|
|
+ public function getLastActivity(): ?\DateTimeInterface
|
|
|
{
|
|
|
return $this->lastActivity;
|
|
|
}
|
|
|
|
|
|
- public function setLastActivity($lastActivity)
|
|
|
+ public function setLastActivity(?\DateTimeInterface $lastActivity): self
|
|
|
{
|
|
|
$this->lastActivity = $lastActivity;
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
- public function isActiveNow()
|
|
|
+ public function isActiveNow(): bool
|
|
|
{
|
|
|
$delay = new \DateTime('5 minutes ago');
|
|
|
|
|
|
return ( $this->getLastActivity() > $delay );
|
|
|
}
|
|
|
|
|
|
- public function getId()
|
|
|
+ public function getId(): ?int
|
|
|
{
|
|
|
return $this->id;
|
|
|
}
|
|
|
|
|
|
- public function setUsername($username)
|
|
|
+ public function setUsername($username): self
|
|
|
{
|
|
|
$this->username = $username;
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function getUsername()
|
|
|
+ public function getUsername(): ?string
|
|
|
{
|
|
|
return (string) $this->username;
|
|
|
}
|
|
|
|
|
|
- public function getUserIdentifier()
|
|
|
+ public function getUserIdentifier(): ?string
|
|
|
{
|
|
|
return $this->username;
|
|
|
}
|
|
|
|
|
|
- public function setActivated($activated)
|
|
|
+ public function setActivated($activated): self
|
|
|
{
|
|
|
$this->isActive = $activated;
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
- public function getActivated()
|
|
|
+ public function getActivated(): bool
|
|
|
{
|
|
|
return $this->isActive;
|
|
|
}
|
|
|
|
|
|
- public function getPrenom()
|
|
|
+ public function getPrenom(): ?string
|
|
|
{
|
|
|
return $this->prenom;
|
|
|
}
|
|
|
|
|
|
- public function setPrenom($prenom)
|
|
|
+ public function setPrenom($prenom): self
|
|
|
{
|
|
|
$this->prenom = $prenom;
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
- public function getNom()
|
|
|
+ public function getNom(): ?string
|
|
|
{
|
|
|
return $this->nom;
|
|
|
}
|
|
|
|
|
|
- public function setNom($nom)
|
|
|
+ public function setNom($nom): self
|
|
|
{
|
|
|
$this->nom = $nom;
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
- public function getMail()
|
|
|
+ public function getMail(): ?string
|
|
|
{
|
|
|
return $this->mail;
|
|
|
}
|
|
|
|
|
|
- public function setMail($mail)
|
|
|
+ public function setMail($mail): self
|
|
|
{
|
|
|
$this->mail = $mail;
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
- public function setPassword($password)
|
|
|
+ public function setPassword($password): self
|
|
|
{
|
|
|
$this->password = $password;
|
|
|
|
|
@@ -160,24 +171,24 @@ class User implements UserInterface,PasswordAuthenticatedUserInterface
|
|
|
return $this->password;
|
|
|
}
|
|
|
|
|
|
- public function setSalt($salt)
|
|
|
+ public function setSalt($salt): self
|
|
|
{
|
|
|
$this->salt = $salt;
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function getSalt()
|
|
|
+ public function getSalt(): ?string
|
|
|
{
|
|
|
return $this->salt;
|
|
|
}
|
|
|
|
|
|
- public function getToken()
|
|
|
+ public function getToken(): ?string
|
|
|
{
|
|
|
return $this->token;
|
|
|
}
|
|
|
|
|
|
- public function setToken($token)
|
|
|
+ public function setToken($token): self
|
|
|
{
|
|
|
//$this->token = hash("sha512", uniqid());
|
|
|
$this->token = $token;
|
|
@@ -186,37 +197,44 @@ class User implements UserInterface,PasswordAuthenticatedUserInterface
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function getTokenValidity()
|
|
|
+ public function getTokenValidity(): ?\DateTimeInterface
|
|
|
{
|
|
|
return $this->tokenValidity;
|
|
|
}
|
|
|
|
|
|
- private function setTokenValidity(\DateTime $tokenValidity)
|
|
|
+ private function setTokenValidity(\DateTimeInterface $tokenValidity)
|
|
|
{
|
|
|
$this->tokenValidity = $tokenValidity;
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function isValidToken()
|
|
|
+ public function isValidToken(): bool
|
|
|
{
|
|
|
- $expire = $this->getTokenValidity()->modify('+1 hour');
|
|
|
+ $expire = (new \DateTime($this->getTokenValidity()->format("Y-m-d H:i:s")))->modify('+1 hour');
|
|
|
+ dump($expire);
|
|
|
+ dump(new \DateTime('now'));
|
|
|
return ( $expire > new \DateTime('now') );
|
|
|
}
|
|
|
|
|
|
- public function setRoles($roles)
|
|
|
+ public function setRoles($roles): self
|
|
|
{
|
|
|
$this->roles = $roles;
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function getRoles()
|
|
|
+ /**
|
|
|
+ * @see UserInterface
|
|
|
+ */
|
|
|
+ public function getRoles(): array
|
|
|
{
|
|
|
- return $this->roles;
|
|
|
+ $roles = $this->roles;
|
|
|
+ return array_unique($roles);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- public function eraseCredentials()
|
|
|
+ public function eraseCredentials(): void
|
|
|
{
|
|
|
|
|
|
}
|
|
@@ -231,43 +249,47 @@ class User implements UserInterface,PasswordAuthenticatedUserInterface
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
|
|
- public function addFilm(\App\Entity\Film $film)
|
|
|
+ public function addFilm(\App\Entity\Film $film): self
|
|
|
{
|
|
|
$this->films[] = $film;
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function removeFilm(\App\Entity\Film $film)
|
|
|
+ public function removeFilm(\App\Entity\Film $film): self
|
|
|
{
|
|
|
$this->films->removeElement($film);
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
- public function getFilms()
|
|
|
+ public function getFilms(): Collection
|
|
|
{
|
|
|
return $this->films;
|
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
- public function addFilmVu(\App\Entity\Film $film)
|
|
|
+ public function addFilmVu(\App\Entity\Film $film): self
|
|
|
{
|
|
|
$this->filmsVus[] = $film;
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function removeFilmVu(\App\Entity\Film $film)
|
|
|
+ public function removeFilmVu(\App\Entity\Film $film): self
|
|
|
{
|
|
|
$this->filmsVus->removeElement($film);
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
- public function getFilmsVus()
|
|
|
+ public function getFilmsVus(): Collection
|
|
|
{
|
|
|
return $this->filmsVus;
|
|
|
}
|
|
|
|
|
|
- public function getNomComplet()
|
|
|
+ public function getNomComplet(): ?string
|
|
|
{
|
|
|
if ($this->prenom == null && $this->nom == null)
|
|
|
{
|
|
@@ -276,27 +298,27 @@ class User implements UserInterface,PasswordAuthenticatedUserInterface
|
|
|
return $this->getPrenom()." ".$this->getNom();
|
|
|
}
|
|
|
|
|
|
- public function isAccountNonExpired()
|
|
|
+ public function isAccountNonExpired(): bool
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public function isAccountNonLocked()
|
|
|
+ public function isAccountNonLocked(): bool
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public function isCredentialsNonExpired()
|
|
|
+ public function isCredentialsNonExpired(): bool
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public function isEnabled()
|
|
|
+ public function isEnabled(): bool
|
|
|
{
|
|
|
return $this->isActive;
|
|
|
}
|
|
|
|
|
|
- public function serialize()
|
|
|
+ public function serialize(): ?string
|
|
|
{
|
|
|
return serialize(array(
|
|
|
$this->id,
|
|
@@ -308,7 +330,7 @@ class User implements UserInterface,PasswordAuthenticatedUserInterface
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- public function unserialize($serialized)
|
|
|
+ public function unserialize($serialized):void
|
|
|
{
|
|
|
list (
|
|
|
$this->id,
|
|
@@ -321,12 +343,12 @@ class User implements UserInterface,PasswordAuthenticatedUserInterface
|
|
|
) = unserialize($serialized, array('allowed_classes' => false));
|
|
|
}
|
|
|
|
|
|
- public function wantToSee(Film $film)
|
|
|
+ public function wantToSee(Film $film): bool
|
|
|
{
|
|
|
return $this->getFilms()->contains($film);
|
|
|
}
|
|
|
|
|
|
- public function haveSeen(Film $film)
|
|
|
+ public function haveSeen(Film $film): bool
|
|
|
{
|
|
|
return $this->getFilmsVus()->contains($film);
|
|
|
}
|