src/Entity/Society.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SocietyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11.  * @ORM\Entity(repositoryClass=SocietyRepository::class)
  12.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  13.  */
  14. class Society implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=180, unique=true)
  24.      */
  25.     private $email;
  26.     /**
  27.      * @ORM\Column(type="json")
  28.      */
  29.     private $roles = [];
  30.     /**
  31.      * @var string The hashed password
  32.      * @ORM\Column(type="string")
  33.      */
  34.     private $password;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $name null;
  39.     /**
  40.      * @ORM\OneToMany(targetEntity="App\Entity\Fpc", mappedBy="society", orphanRemoval=true)
  41.      */
  42.     private Collection $fpcs;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity="App\Entity\Ias", mappedBy="society", orphanRemoval=true)
  45.      */
  46.     private Collection $ias;
  47.     /**
  48.      * @ORM\Column(type="string", length=255)
  49.      */
  50.     private $logo;
  51.     public function __construct()
  52.     {
  53.         $this->fpcs = new ArrayCollection();
  54.         $this->ias = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getEmail(): ?string
  61.     {
  62.         return $this->email;
  63.     }
  64.     public function setEmail(string $email): self
  65.     {
  66.         $this->email $email;
  67.         return $this;
  68.     }
  69.     /**
  70.      * A visual identifier that represents this user.
  71.      *
  72.      * @see UserInterface
  73.      */
  74.     public function getUserIdentifier(): string
  75.     {
  76.         return (string) $this->email;
  77.     }
  78.     /**
  79.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  80.      */
  81.     public function getUsername(): string
  82.     {
  83.         return (string) $this->email;
  84.     }
  85.     /**
  86.      * @see UserInterface
  87.      */
  88.     public function getRoles(): array
  89.     {
  90.         $roles $this->roles;
  91.         // guarantee every user at least has ROLE_USER
  92.         $roles[] = 'ROLE_USER';
  93.         return array_unique($roles);
  94.     }
  95.     public function setRoles(array $roles): self
  96.     {
  97.         $this->roles $roles;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @see PasswordAuthenticatedUserInterface
  102.      */
  103.     public function getPassword(): string
  104.     {
  105.         return $this->password;
  106.     }
  107.     public function setPassword(string $password): self
  108.     {
  109.         $this->password $password;
  110.         return $this;
  111.     }
  112.     /**
  113.      * Returning a salt is only needed, if you are not using a modern
  114.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  115.      *
  116.      * @see UserInterface
  117.      */
  118.     public function getSalt(): ?string
  119.     {
  120.         return null;
  121.     }
  122.     /**
  123.      * @see UserInterface
  124.      */
  125.     public function eraseCredentials()
  126.     {
  127.         // If you store any temporary, sensitive data on the user, clear it here
  128.         // $this->plainPassword = null;
  129.     }
  130.     public function getName(): ?string
  131.     {
  132.         return $this->name;
  133.     }
  134.     public function setName(string $name): self
  135.     {
  136.         $this->name $name;
  137.         return $this;
  138.     }
  139.     /**
  140.      * @return Collection<int, Fpc>
  141.      */
  142.     public function getFpcs(): Collection
  143.     {
  144.         return $this->fpcs;
  145.     }
  146.     public function addFpc(Fpc $fpc): self
  147.     {
  148.         if (!$this->fpcs->contains($fpc)) {
  149.             $this->fpcs->add($fpc);
  150.             $fpc->setSociety($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeFpc(Fpc $fpc): self
  155.     {
  156.         if ($this->fpcs->removeElement($fpc)) {
  157.             // set the owning side to null (unless already changed)
  158.             if ($fpc->getSociety() === $this) {
  159.                 $fpc->setSociety(null);
  160.             }
  161.         }
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return Collection<int, Ias>
  166.      */
  167.     public function getIas(): Collection
  168.     {
  169.         return $this->ias;
  170.     }
  171.     public function addIa(Ias $ia): self
  172.     {
  173.         if (!$this->ias->contains($ia)) {
  174.             $this->ias->add($ia);
  175.             $ia->setSociety($this);
  176.         }
  177.         return $this;
  178.     }
  179.     public function removeIa(Ias $ia): self
  180.     {
  181.         if ($this->ias->removeElement($ia)) {
  182.             // set the owning side to null (unless already changed)
  183.             if ($ia->getSociety() === $this) {
  184.                 $ia->setSociety(null);
  185.             }
  186.         }
  187.         return $this;
  188.     }
  189.     public function getLogo(): ?string
  190.     {
  191.         return $this->logo;
  192.     }
  193.     public function setLogo(string $logo): self
  194.     {
  195.         $this->logo $logo;
  196.         return $this;
  197.     }
  198. }