<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: 'SpecialUserRepository')]
#[ORM\Table(name: 'SpecialUsers')]
class SpecialUser implements PasswordAuthenticatedUserInterface
{
public $active;
#[ORM\Column(type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private readonly int $id;
#[Assert\NotBlank(message: 'The username should not be blank')]
#[ORM\Column(type: 'string', length: 25, unique: true)]
private ?string $username = null;
#[ORM\Column(type: 'string', length: 64)]
private ?string $password = null;
#[Assert\NotBlank(message: 'The email should not be blank')]
#[Assert\Email]
#[ORM\Column(type: 'string', length: 60, unique: true)]
private ?string $email = null;
#[ORM\Column(name: 'name', type: 'string', nullable: true)]
private ?string $name = null;
#[ORM\Column(name: 'is_active', type: 'boolean')]
private bool $isActive = true;
#[ORM\Column(type: 'array')]
private ?array $roles = null;
#[ORM\Column(name: 'emailresetkey', type: 'string', nullable: true)]
private ?string $emailresetkey = null;
#[Assert\Length(max: 4096)]
private $plainPassword;
public function __construct() {}
public function getUsername()
{
return $this->username;
}
public function getSalt()
{
// you *may* need a real salt depending on your encoder
// see section on salt below
return null;
}
public function getPassword(): ?string
{
return $this->password;
}
public function eraseCredentials() {}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize([
$this->id,
$this->username,
$this->password,
$this->active,
// see section on salt below
// $this->salt,
]);
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
[$this->id, $this->username, $this->password, $this->isActive] = unserialize($serialized);
}
/**
* 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;
}
/**
* Set password.
*
* @param string $password
*
* @return User
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Set email.
*
* @param string $email
*
* @return User
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email.
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set name.
*
* @param string $name
*
* @return User
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set isActive.
*
* @param bool $isActive
*
* @return User
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive.
*
* @return bool
*/
public function getIsActive()
{
return $this->isActive;
}
public function isAccountNonExpired()
{
return true;
}
public function isAccountNonLocked()
{
return true;
}
public function isCredentialsNonExpired()
{
return true;
}
public function isEnabled()
{
return $this->isActive;
}
public function getRoles()
{
return $this->roles;
}
public function getPlainPassword()
{
return $this->plainPassword;
}
public function setPlainPassword($password)
{
$this->plainPassword = $password;
}
/**
* Set roles.
*
* @param array $roles
*
* @return User
*/
public function setRoles($roles)
{
$this->roles = $roles;
return $this;
}
public function addRole($role)
{
$role = strtoupper((string) $role);
if (!in_array($role, $this->roles, true)) {
$this->roles[] = $role;
}
return $this;
}
/**
* Set emailresetkey.
*
* @param string $emailresetkey
*
* @return User
*/
public function setEmailresetkey($emailresetkey)
{
$this->emailresetkey = $emailresetkey;
return $this;
}
/**
* Get emailresetkey.
*
* @return string
*/
public function getEmailresetkey()
{
return $this->emailresetkey;
}
public function getUserIdentifier()
{
return $this->username;
}
}