src/Entity/Language.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\HashTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Persistence\Event\LifecycleEventArgs;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\HasLifecycleCallbacks()
  10.  * @ORM\Entity(repositoryClass="App\Repository\LanguageRepository")
  11.  */
  12. class Language
  13. {
  14.     use HashTrait;
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private int $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=25)
  23.      */
  24.     private string $name;
  25.     /**
  26.      * @ORM\Column(type="string", length=2, options={"comment":"ISO-639-1"})
  27.      */
  28.     private string $code;
  29.     /**
  30.      * @var ArrayCollection|Headquarter[]
  31.      *
  32.      * @ORM\ManyToMany(targetEntity="App\Entity\Headquarter", mappedBy="languages")
  33.      */
  34.     private $headquarters;
  35.     public function __construct()
  36.     {
  37.         $this->headquarters = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): self
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     public function getCode(): ?string
  53.     {
  54.         return $this->code;
  55.     }
  56.     public function setCode(string $code): self
  57.     {
  58.         $this->code $code;
  59.         return $this;
  60.     }
  61.     /**
  62.      * @return Collection|Headquarter[]
  63.      */
  64.     public function getHeadquarters(): Collection
  65.     {
  66.         return $this->headquarters;
  67.     }
  68.     public function addHeadquarters(Headquarter $headquarters): self
  69.     {
  70.         if (!$this->headquarters->contains($headquarters)) {
  71.             $this->headquarters[] = $headquarters;
  72.             $headquarters->addLanguage($this);
  73.         }
  74.         return $this;
  75.     }
  76.     public function removeHeadquarters(Headquarter $headquarters): self
  77.     {
  78.         if ($this->headquarters->removeElement($headquarters)) {
  79.             $headquarters->removeLanguage($this);
  80.         }
  81.         return $this;
  82.     }
  83. }