<?phpnamespace App\Core\Entities;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Doctrine\ORM\Mapping\MappedSuperclass;use Symfony\Component\Security\Core\User\UserInterface;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Gedmo\Mapping\Annotation\Timestampable;use Symfony\Component\Serializer\Annotation\Groups;// #[ORM\Entity(repositoryClass: UserRepository::class)]#[MappedSuperclass] // https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/inheritance-mapping.html#association-overrideclass UserEntity implements UserInterface, PasswordAuthenticatedUserInterface{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: Types::INTEGER)] #[Groups(['read'])] private int $id; #[Groups(['read'])] #[ORM\Column(type: Types::STRING, length: 255, unique: true)] private string $email; #[ORM\Column(type: Types::STRING, length: 255)] private string $password; #[ORM\Column(type: Types::JSON)] protected array $roles = []; #[Timestampable(on: 'create')] #[ORM\Column(type: Types::DATETIME_MUTABLE)] protected $createdAt; #[Timestampable(on: 'update')] #[ORM\Column(type: Types::DATETIME_MUTABLE)] protected $updatedAt; public function getId(): ?int { return $this->id; } /** * Set email * * @param [type] $email * @return self */ public function setEmail($email): self { $this->email = $email; return $this; } /** * Get email * * @return string|null */ public function getEmail(): ?string { return $this->email; } /** * {@inheritdoc} */ public function eraseCredentials(): void { // if you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } /** * {@inheritdoc} */ public function getPassword(): string { return (string) $this->password; } public function setPassword(string $password): void { $this->password = $password; } /** * @return array<int, string> */ public function getRoles(): array { $roles = $this->roles; // guarantee every user at least has ROLE_USER $roles[] = 'ROLE_USER'; return \array_unique($roles); } /** * @param array<int, string> $roles */ public function setRoles(array $roles): void { $this->roles = $roles; } /** * {@inheritdoc} */ public function getSalt(): ?string { return null; } /** * {@inheritdoc} */ public function getUsername(): string { return (string) $this->email; } public function getUserIdentifier(): string { return (string) $this->email; }}