src/Entity/Language.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\LanguageRepository")
  8.  * @ORM\Table(name="languages", indexes={@ORM\Index(name="id_index", columns={"id"})})
  9.  */
  10. class Language
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\Column(type="integer")
  15.      * @ORM\GeneratedValue(strategy="AUTO")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", unique=true, length=20, nullable=false)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="string", unique=true, length=2, nullable=false)
  24.      */
  25.     private $code;
  26.     /**
  27.      * @ORM\Column(type="boolean", nullable=false)
  28.      */
  29.     private $status;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="language")
  32.      */
  33.     private $users;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity="App\Entity\NotificationTemplate", mappedBy="language")
  36.      */
  37.     private $notificationTemplates;
  38.     public function __construct()
  39.     {
  40.         $this->users = new ArrayCollection();
  41.         $this->notificationTemplates = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(string $name): self
  52.     {
  53.         $this->name $name;
  54.         return $this;
  55.     }
  56.     public function getCode(): ?string
  57.     {
  58.         return $this->code;
  59.     }
  60.     public function setCode(string $code): self
  61.     {
  62.         $this->code $code;
  63.         return $this;
  64.     }
  65.     public function getStatus(): ?bool
  66.     {
  67.         return $this->status;
  68.     }
  69.     public function setStatus(bool $status): self
  70.     {
  71.         $this->status $status;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return Collection<int, User>
  76.      */
  77.     public function getUsers(): Collection
  78.     {
  79.         return $this->users;
  80.     }
  81.     public function addUser(User $user): self
  82.     {
  83.         if (!$this->users->contains($user)) {
  84.             $this->users[] = $user;
  85.             $user->setLanguage($this);
  86.         }
  87.         return $this;
  88.     }
  89.     public function removeUser(User $user): self
  90.     {
  91.         if ($this->users->removeElement($user)) {
  92.             // set the owning side to null (unless already changed)
  93.             if ($user->getLanguage() === $this) {
  94.                 $user->setLanguage(null);
  95.             }
  96.         }
  97.         return $this;
  98.     }
  99.     /**
  100.      * @return Collection<int, NotificationTemplate>
  101.      */
  102.     public function getNotificationTemplates(): Collection
  103.     {
  104.         return $this->notificationTemplates;
  105.     }
  106.     public function addNotificationTemplate(NotificationTemplate $notificationTemplate): self
  107.     {
  108.         if (!$this->notificationTemplates->contains($notificationTemplate)) {
  109.             $this->notificationTemplates[] = $notificationTemplate;
  110.             $notificationTemplate->setLanguage($this);
  111.         }
  112.         return $this;
  113.     }
  114.     public function removeNotificationTemplate(NotificationTemplate $notificationTemplate): self
  115.     {
  116.         if ($this->notificationTemplates->removeElement($notificationTemplate)) {
  117.             // set the owning side to null (unless already changed)
  118.             if ($notificationTemplate->getLanguage() === $this) {
  119.                 $notificationTemplate->setLanguage(null);
  120.             }
  121.         }
  122.         return $this;
  123.     }
  124. }