<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* UserAction
*
* @ORM\Table(name="fos_user")
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $username;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="array")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @var boolean
* Activer ou desactiver le rappel automatique de changement de mot de passe
* @ORM\Column(name="rappel", type="boolean")
*/
private $rappel = true;
/**
* @var boolean
* Activer ou desactiver utilisateur
* @ORM\Column(name="enabled", type="boolean")
*/
private $enabled = true;
/**
* @var boolean
* set if remainder is sent
* @ORM\Column(name="two_week_remainder_sent", type="boolean")
*/
private $twoWeekRemainderSent = false;
/**
* @var boolean
* set if remainder is sent
* @ORM\Column(name="one_week_remainder_sent", type="boolean")
*/
private $oneWeekRemainderSent = false;
/**
*
* @ORM\Column(type="datetime", nullable = true)
*/
private $passwordUpdatedAt;
/**
*
* @ORM\Column(type="datetime", nullable = true)
*/
private $lastLogin;
/**
*
* @ORM\Column(type="string", nullable = true)
*/
private $oldPasswords;
const ROLE_DEFAULT = '';
const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
public function getId(): ?int
{
return $this->id;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->username;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* Set rappel.
*
* @param bool $rappel
*
* @return User
*/
public function setRappel($rappel)
{
$this->rappel = $rappel;
return $this;
}
/**
* Get rappel.
*
* @return bool
*/
public function getRappel()
{
return $this->rappel;
}
/**
* Set passwordUpdatedAt.
*
* @param \DateTime|null $passwordUpdatedAt
*
* @return User
*/
public function setPasswordUpdatedAt($passwordUpdatedAt = null)
{
$this->passwordUpdatedAt = $passwordUpdatedAt;
return $this;
}
/**
* Get passwordUpdatedAt.
*
* @return \DateTime|null
*/
public function getPasswordUpdatedAt()
{
return $this->passwordUpdatedAt;
}
/**
* Set oldPasswords.
*
* @param string|null $oldPasswords
*
* @return User
*/
public function setOldPasswords($oldPasswords = null)
{
$this->oldPasswords = $oldPasswords;
return $this;
}
/**
* Get oldPasswords.
*
* @return string|null
*/
public function getOldPasswords()
{
return $this->oldPasswords;
}
/**
* Set twoWeekRemainderSent.
*
* @param bool $twoWeekRemainderSent
*
* @return User
*/
public function setTwoWeekRemainderSent($twoWeekRemainderSent)
{
$this->twoWeekRemainderSent = $twoWeekRemainderSent;
return $this;
}
/**
* Get twoWeekRemainderSent.
*
* @return bool
*/
public function getTwoWeekRemainderSent()
{
return $this->twoWeekRemainderSent;
}
/**
* Set oneWeekRemainderSent.
*
* @param bool $oneWeekRemainderSent
*
* @return User
*/
public function setOneWeekRemainderSent($oneWeekRemainderSent)
{
$this->oneWeekRemainderSent = $oneWeekRemainderSent;
return $this;
}
/**
* Get oneWeekRemainderSent.
*
* @return bool
*/
public function getOneWeekRemainderSent()
{
return $this->oneWeekRemainderSent;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function isRappel(): ?bool
{
return $this->rappel;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
return $this;
}
public function isTwoWeekRemainderSent(): ?bool
{
return $this->twoWeekRemainderSent;
}
public function isOneWeekRemainderSent(): ?bool
{
return $this->oneWeekRemainderSent;
}
public function getLastLogin(): ?\DateTimeInterface
{
return $this->lastLogin;
}
public function setLastLogin(?\DateTimeInterface $lastLogin): self
{
$this->lastLogin = $lastLogin;
return $this;
}
public function hasRole(string $role): ?bool
{
return in_array($role, $this->roles);
}
public function addRole(string $role): self
{
if (!in_array($role, $this->roles)) {
$this->roles[] = $role;
}
return $this;
}
public function removeRole(string $role): self
{
$this->roles = array_filter($this->roles, static function ($element) use ($role) {
return $element !== $role;
});
return $this;
}
}