| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Person;
- use App\Entity\Core\ContactPoint;
- use App\Repository\Person\PersonRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Security\Core\User\UserInterface;
- /**
- * Personne physique ou morale
- *
- * @ORM\Entity(repositoryClass=PersonRepository::class)
- */
- class Person implements UserInterface
- {
- /**
- * @ORM\Id
- * @ORM\GeneratedValue
- * @ORM\Column(type="integer")
- */
- private $id;
- /**
- * @ORM\Column(type="string", length=180, unique=true)
- */
- private $username;
- /**
- *
- */
- private $roles = [];
- /**
- * @var string The hashed password
- * @ORM\Column(type="string")
- */
- private $password;
- /**
- * @ORM\Column(type="string", length=255, nullable=true)
- */
- private $name;
- /**
- * @ORM\Column(type="string", length=255, nullable=true)
- */
- private $givenName;
- /**
- * @ORM\ManyToMany(targetEntity=ContactPoint::class, mappedBy="person")
- */
- private $contactPoints;
- public function __construct()
- {
- $this->contactPoints = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- /**
- * A visual identifier that represents this user.
- *
- * @see UserInterface
- */
- public function getUsername(): string
- {
- return (string) $this->username;
- }
- public function setUsername(string $username): self
- {
- $this->username = $username;
- 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;
- }
- /**
- * @see UserInterface
- */
- public function getPassword(): string
- {
- return (string) $this->password;
- }
- public function setPassword(string $password): self
- {
- $this->password = $password;
- return $this;
- }
- /**
- * @see UserInterface
- */
- public function getSalt()
- {
- // not needed when using the "bcrypt" algorithm in security.yaml
- }
- /**
- * @see UserInterface
- */
- 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;
- }
- /**
- * @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;
- }
- }
|