<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass="App\Repository\SuperAdminRepository")
* @ORM\HasLifecycleCallbacks()
*/
class SuperAdmin extends BaseEntity implements UserInterface
{
/**
* @ORM\Column(type="string", length=255,unique=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
*/
private $username;
/**
* @var string The hashed password
* @ORM\Column(type="string", nullable=true)
*/
private $password;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(?string $password): self
{
$this->password = $password;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getUsername(): ?string { return $this->username; } /** * Stable identifier used by Symfony's authenticator manager. */ public function getUserIdentifier(): string { return (string) $this->email; }
public function setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_SUPER_ADMIN';
return array_unique($roles);
}
public function addRole(string $role): self
{
$this->roles[] = $role;
return $this;
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function hasRole(string $role): bool
{
return in_array($role, $this->roles);
}
/**
* @see UserInterface
*/
public function getSalt(): ?string { // not needed when using the "bcrypt" algorithm in security.yaml return null; }
/**
* @see UserInterface
*/
public function eraseCredentials(): void {
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
}