*/ #[ORM\Column(type: 'json')] private array $roles = []; /** * @var string The hashed password */ #[ORM\Column(type: 'string')] private string $password = ''; #[ORM\Column(type: 'string', length: 120, nullable: true)] #[Assert\Length(max: 120)] private ?string $displayName = null; public function getId(): ?int { return $this->id; } public function getEmail(): string { return $this->email; } public function setEmail(string $email): void { $this->email = strtolower($email); } public function getUserIdentifier(): string { return $this->email; } public function getRoles(): array { $roles = $this->roles; // guarantee every user at least has ROLE_USER if (!in_array('ROLE_USER', $roles, true)) { $roles[] = 'ROLE_USER'; } return array_values(array_unique($roles)); } /** * @param list $roles */ public function setRoles(array $roles): void { $this->roles = array_values(array_unique($roles)); } public function addRole(string $role): void { $roles = $this->getRoles(); if (!in_array($role, $roles, true)) { $roles[] = $role; } $this->roles = $roles; } public function getPassword(): string { return $this->password; } public function setPassword(string $hashedPassword): void { $this->password = $hashedPassword; } public function eraseCredentials(): void { // no-op } public function getDisplayName(): ?string { return $this->displayName; } public function setDisplayName(?string $displayName): void { $this->displayName = $displayName; } }