<?php
namespace App\Entity;
use App\Repository\AdminRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=AdminRepository::class)
*/
class Admin implements UserInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $username;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="role", type="string", length=255)
*/
private $role;
/**
* @ORM\Column(type="string", length=255)
*/
private $password;
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime", nullable=true)
*/
private $created;
private $plainPassword;
public function getPlainPassword()
{
return $this->plainPassword;
}
public function __construct()
{
$this->created = new \DateTime();
$this->active = 1;
$this->role = 'ROLE_SUPER_ADMIN';
}
public function setPlainPassword($password)
{
$this->plainPassword = $password;
// Si vous modifiez le mot de passe en clair, le mot de passe haché doit également être modifié
$this->password = null;
}
/**
* @var int
*
* @ORM\Column(name="active", type="integer", nullable=true)
*/
private $active;
public function getId(): ?int
{
return $this->id;
}
public function __toString()
{
return $this->getUsername();
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @param integer $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* Get active
*
* @return integer
*/
public function getActive()
{
return $this->active;
}
/**
* @return string
*/
public function getRole(): ?string
{
return $this->role;
}
/**
* {@inheritdoc}
*/
public function getRoles(): array
{
return [$this->role];
}
/**
* @param string $role
*/
public function setRole(string $role): void
{
$this->role = $role;
}
/**
* @param \DateTime|null $creadted
*/
public function setCreated(?\DateTime $creadted): void
{
$this->created = $creadted;
}
/**
* @return \DateTime|null
*/
public function getCreated(): ?\DateTime
{
return $this->created;
}
/**
* Loads the user for the given username.
*
* @param string $username The username
*
* @return UserInterface
*
* @throws UsernameNotFoundException if the user is not found
*/
public function loadUserByUsername($username)
{
// TODO: Implement loadUserByUsername() method.
}
/**
* Refreshes the user for the account interface.
*
* @param UserInterface $user
*
* @return UserInterface
*
* @throws UnsupportedUserException if the account is not supported
*/
public function refreshUser(UserInterface $user)
{
// TODO: Implement refreshUser() method.
}
/**
* @param string $class
*
* @return bool
*/
public function supportsClass($class)
{
// TODO: Implement supportsClass() method.
}
/**
* @return null
*/
public function getSalt()
{
return null;
}
public function eraseCredentials() {}
}