["security" => "is_granted('ROLE_USERS_VIEW')"], ] )] #[ORM\Entity(repositoryClass: PersonRepository::class)] class Person implements UserInterface { #[ORM\Id] #[ORM\Column] #[ORM\GeneratedValue] private ?int $id = null; #[ORM\Column(length: 180, unique: true, nullable: true)] private ?string $username = null; private array $roles = []; #[ORM\Column(nullable: true)] private ?string $password = null; #[ORM\Column(length: 255, nullable: true)] #[Groups(["access_people_ref", "access_address"])] private ?string $name = null; #[ORM\Column(length: 255, nullable: true)] #[Groups(["access_people_ref", "access_address"])] private ?string $givenName = null; #[ORM\ManyToMany(targetEntity: ContactPoint::class, mappedBy: 'person')] private Collection $contactPoints; #[ORM\OneToMany( mappedBy: 'person', targetEntity: PersonAddressPostal::class, orphanRemoval: true)] #[Groups("access_address")] private Collection $personAddressPostal; #[ORM\Column(nullable: true)] #[Assert\Choice(callback: ['\App\Enum\Person\GenderEnum', 'toArray'], message: 'invalid-gender')] private ?string $gender = null; #[ORM\ManyToOne(inversedBy: 'personImages')] #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')] private ?File $image = null; #[ORM\Column(options: ['default' => true])] private bool $isPhysical = true; #[Pure] public function __construct() { $this->contactPoints = new ArrayCollection(); $this->personAddressPostal = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getUsername(): ?string { return (string) $this->username; } public function getUserIdentifier(): ?string { return (string) $this->username; } public function setUsername(?string $username): self { $this->username = $username; return $this; } 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 getPassword(): ?string { return (string) $this->password; } public function setPassword(?string $password): self { $this->password = $password; return $this; } public function getSalt(): ?string { return null; // not needed when using the "bcrypt" algorithm in security.yaml } public function eraseCredentials() { // If you store any temporary, sensitive data on the user, clear it here // $this->plainPassword = null; } public function getName(): ?string { return $this->name; } public function setName(?string $name): self { $this->name = $name; return $this; } public function getGivenName(): ?string { return $this->givenName; } public function setGivenName(?string $givenName): self { $this->givenName = $givenName; return $this; } public function setGender(?string $gender): self { $this->gender = $gender; return $this; } public function getGender(): ?string { return $this->gender; } /** * @return Collection|ContactPoint[] */ public function getContactPoints(): Collection { return $this->contactPoints; } public function addContactPoint(ContactPoint $contactPoint): self { if (!$this->contactPoints->contains($contactPoint)) { $this->contactPoints[] = $contactPoint; $contactPoint->addPerson($this); } return $this; } public function removeContactPoint(ContactPoint $contactPoint): self { if ($this->contactPoints->removeElement($contactPoint)) { $contactPoint->removePerson($this); } return $this; } public function setImage(?File $image):self { $this->image = $image; return $this; } public function getImage(): ?File { return $this->image; } public function getPersonAddressPostal(): Collection { return $this->personAddressPostal; } public function addPersonAddressPostal(PersonAddressPostal $personAddressPostal): self { if (!$this->personAddressPostal->contains($personAddressPostal)) { $this->personAddressPostal[] = $personAddressPostal; $personAddressPostal->setPerson($this); } return $this; } public function removePersonAddressPostal(PersonAddressPostal $personAddressPostal): self { if ($this->personAddressPostal->removeElement($personAddressPostal)) { // set the owning side to null (unless already changed) if ($personAddressPostal->getPerson() === $this) { $personAddressPostal->setPerson(null); } } return $this; } public function getIsPhysical(): ?bool { return $this->isPhysical; } public function setAdminAccess(bool $isPhysical): self { $this->isPhysical = $isPhysical; return $this; } }