src/Entity/Gos/AlertType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Table()
  8.  * @ORM\Entity(repositoryClass="App\Repository\Gos\AlertTypeRepository")
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class AlertType
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="boolean", nullable=true)
  21.      */
  22.     private $isActive;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Alert", mappedBy="type")
  29.      */
  30.     private $alerts;
  31.     /**
  32.      * @ORM\Column(type="datetime")
  33.      */
  34.     private $createdAt;
  35.     /**
  36.      * @ORM\Column(type="datetime", nullable=true)
  37.      */
  38.     private $updatedAt;
  39.     public function __construct()
  40.     {
  41.         $this->alerts = new ArrayCollection();
  42.     }
  43.     /** @ORM\PrePersist() */
  44.     public function prePersist()
  45.     {
  46.         $this->createdAt = new \DateTime();
  47.     }
  48.     /** @ORM\PreUpdate() */
  49.     public function preUpdate()
  50.     {
  51.         $this->updatedAt = new \DateTime();
  52.     }
  53.     public function __toString()
  54.     {
  55.         return (string)$this->name;
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getIsActive(): ?bool
  62.     {
  63.         return $this->isActive;
  64.     }
  65.     public function setIsActive(?bool $isActive): self
  66.     {
  67.         $this->isActive $isActive;
  68.         return $this;
  69.     }
  70.     public function getName(): ?string
  71.     {
  72.         return $this->name;
  73.     }
  74.     public function setName(string $name): self
  75.     {
  76.         $this->name $name;
  77.         return $this;
  78.     }
  79.     public function getCreatedAt(): ?\DateTimeInterface
  80.     {
  81.         return $this->createdAt;
  82.     }
  83.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  84.     {
  85.         $this->createdAt $createdAt;
  86.         return $this;
  87.     }
  88.     public function getUpdatedAt(): ?\DateTimeInterface
  89.     {
  90.         return $this->updatedAt;
  91.     }
  92.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  93.     {
  94.         $this->updatedAt $updatedAt;
  95.         return $this;
  96.     }
  97.     /**
  98.      * @return Collection|Alert[]
  99.      */
  100.     public function getAlerts(): Collection
  101.     {
  102.         return $this->alerts;
  103.     }
  104.     public function addAlert(Alert $alert): self
  105.     {
  106.         if (!$this->alerts->contains($alert)) {
  107.             $this->alerts[] = $alert;
  108.             $alert->setType($this);
  109.         }
  110.         return $this;
  111.     }
  112.     public function removeAlert(Alert $alert): self
  113.     {
  114.         if ($this->alerts->contains($alert)) {
  115.             $this->alerts->removeElement($alert);
  116.             // set the owning side to null (unless already changed)
  117.             if ($alert->getType() === $this) {
  118.                 $alert->setType(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     public function getLabelName()
  124.     {
  125.         switch ($this->id)
  126.         {
  127.             case 1:
  128.                 return 'backend.alerts.label.products';
  129.                 break;
  130.             case 2:
  131.                 return 'backend.alerts.label.coupons';
  132.                 break;
  133.             default:
  134.                 return 'backend.alerts.wrongId';
  135.                 break;
  136.         }
  137.     }
  138.     public function getTranslatedName()
  139.     {
  140.         switch ($this->id)
  141.         {
  142.             case 1:
  143.                 return 'backend.alerts.table.products';
  144.                 break;
  145.             case 2:
  146.                 return 'backend.alerts.table.coupons';
  147.                 break;
  148.             default:
  149.                 return 'backend.alerts.wrongId';
  150.                 break;
  151.         }
  152.     }
  153. }