src/Entity/User.php line 16
<?phpnamespace App\Entity;use App\Donation\DonationLevelEnum;use App\Repository\UserRepository;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: UserRepository::class)]#[ORM\HasLifecycleCallbacks]#[UniqueEntity(fields: ['userName'], message: 'There is already an account with this username, please pick another one.')]class User implements UserInterface, PasswordAuthenticatedUserInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 320,// unique: true // TODO DEMO FIXIT)]// #[Assert\Email] // TODO DEMO FIXITprivate ?string $email = 'disabled for the demo';#[ORM\Column]private array $roles = [];/*** @var string|null/string The hashed password*/#[ORM\Column(length: 255)]// #[Assert\NotCompromisedPassword(// message: 'The password is too weak, it must not be used. Please use another password.'// )]#[Assert\Length(min: 2, // todo DEMO FIX ITminMessage: 'Your password should be at least {{ limit }} characters')]private ?string $password = null;#[ORM\Column(length: 255)]#[Assert\NotBlank]private ?string $fullName = 'disabled for the demo';#[ORM\Column(length: 255)]#[Assert\NotBlank]private ?string $employer = 'disabled for the demo';#[ORM\Column(length: 255)]#[Assert\NotBlank]private ?string $occupation = 'disabled for the demo';#[ORM\Column(nullable: false,enumType: DonationLevelEnum::class,options: ['unsigned' => true])]#[Assert\Type(type: DonationLevelEnum::class,groups: ['registration_step_stop'])]private ?DonationLevelEnum $transactionDefaultAmount = DonationLevelEnum::One;#[ORM\Column]private ?\DateTimeImmutable $createdAt = null;#[ORM\Column(nullable: true)]private ?\DateTimeImmutable $lastLoginAt = null;#[ORM\Column]private bool $active = false;#[ORM\Column(length: 255, unique: true)]private ?string $userName = null;public function activate(): self{$this->active = true;return $this;}/*** @see UserInterface*/public function eraseCredentials(){// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function getCreatedAt(): ?\DateTimeImmutable{return $this->createdAt;}#[ORM\PrePersist]public function setCreatedAt(): self{$this->createdAt = new \DateTimeImmutable();return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(string $email): self{$this->email = $email;return $this;}public function getEmployer(): ?string{return $this->employer;}public function setEmployer(string $employer): self{$this->employer = $employer;return $this;}public function getFullName(): ?string{return $this->userName;}public function setFullName(string $fullName): self{$this->fullName = $fullName;return $this;}public function getId(): ?int{return $this->id;}public function getLastLoginAt(): ?\DateTimeImmutable{return $this->lastLoginAt;}public function setLastLoginAt(?\DateTimeImmutable $lastLoginAt): self{$this->lastLoginAt = $lastLoginAt;return $this;}public function getOccupation(): ?string{return $this->occupation;}public function setOccupation(string $occupation): self{$this->occupation = $occupation;return $this;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}/*** @see UserInterface*/public function getRoles(): array{$roles = $this->roles;// guarantee every user at least has ROLE_USER$roles[] = 'ROLE_USER';return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}public function getTransactionDefaultAmount(): int{return $this->transactionDefaultAmount->value;}public function setTransactionDefaultAmount(DonationLevelEnum $transactionDefaultAmount): self{$this->transactionDefaultAmount = $transactionDefaultAmount;return $this;}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{return (string)$this->email;}public function getUserName(): ?string{return $this->userName;}public function setUserName(string $userName): self{$this->userName = $userName;return $this;}public function isActive(): ?bool{return $this->active;}// TODO DEMO FIXIT// #[Assert\IsTrue(message: 'The password cannot match your name or email')]// public function isPasswordSafe(): bool// {// return !($this->fullName == $this->password || $this->email == $this->password);// }}