['me:read']], ), new Get( security: "is_granted('ROLE_ADMIN')", normalizationContext: ['groups' => ['user:list']], ), new GetCollection( security: "is_granted('ROLE_ADMIN')", normalizationContext: ['groups' => ['user:list']], ), new Post(security: "is_granted('ROLE_ADMIN')", processor: UserPasswordHasherProcessor::class), new Patch(security: "is_granted('ROLE_ADMIN')", processor: UserPasswordHasherProcessor::class), new Delete(security: "is_granted('ROLE_ADMIN')"), ], denormalizationContext: ['groups' => ['user:write']], )] #[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\Table(name: '`user`')] class User implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['me:read', 'user:list'])] private ?int $id = null; #[ORM\Column(length: 180, unique: true)] #[Groups(['me:read', 'user:list', 'user:write'])] private ?string $username = null; /** @var list */ #[ORM\Column] #[Groups(['me:read', 'user:list', 'user:write'])] private array $roles = []; #[ORM\Column] private ?string $password = null; #[Groups(['user:write'])] private ?string $plainPassword = null; #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] private ?DateTimeImmutable $createdAt = null; public function __construct() { $this->createdAt = new DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getUsername(): ?string { return $this->username; } public function setUsername(string $username): static { $this->username = $username; return $this; } public function getUserIdentifier(): string { return (string) $this->username; } /** @return list */ public function getRoles(): array { $roles = $this->roles; $roles[] = 'ROLE_USER'; return array_values(array_unique($roles)); } /** @param list $roles */ public function setRoles(array $roles): static { $this->roles = $roles; return $this; } public function getPassword(): ?string { return $this->password; } public function setPassword(string $password): static { $this->password = $password; return $this; } public function getCreatedAt(): ?DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(DateTimeImmutable $createdAt): static { $this->createdAt = $createdAt; return $this; } public function getPlainPassword(): ?string { return $this->plainPassword; } public function setPlainPassword(?string $plainPassword): static { $this->plainPassword = $plainPassword; return $this; } public function eraseCredentials(): void { $this->plainPassword = null; } }