src/Entity/Alert.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AlertRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. use Gedmo\Translatable\Translatable;
  10. use App\Entity\Translation\AlertTranslation;
  11. use Symfony\Component\Serializer\Annotation\Ignore;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. /**
  14.  * @ORM\Entity(repositoryClass=AlertRepository::class)
  15.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false,hardDelete=false)
  16.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\AlertTranslation")
  17.  */
  18. class Alert implements Translatable
  19. {
  20.     use TimestampableEntity;
  21.     use SetTranslationsTrait;
  22.     public const FIELDS = [
  23.         'content'
  24.      ];
  25.     /**
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue
  28.      * @ORM\Column(type="integer")
  29.      * @Groups("alert:list", "alert:item")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\Column(type="text")
  34.      * @Gedmo\Translatable
  35.      * @Groups("alert:list", "alert:item")
  36.      */
  37.     private $content;
  38.     /**
  39.      * @var string
  40.      * @Ignore()
  41.      */
  42.     private $contentEn;
  43.     /**
  44.      * @var string
  45.      * @Ignore()
  46.      */
  47.     private $contentCa;
  48.     /**
  49.      * @ORM\Column(type="boolean")
  50.      * @Groups("alert:list", "alert:item")
  51.      */
  52.     private $enabled;
  53.     /**
  54.     * @ORM\OneToMany(
  55.     *   targetEntity="App\Entity\Translation\AlertTranslation",
  56.     *   mappedBy="object",
  57.     *   cascade={"persist", "remove"}
  58.     * )
  59.      * @Ignore()
  60.     */
  61.     private $translations;
  62.     /**
  63.      * @ORM\Column(type="datetime", nullable=true)
  64.      * @var \DateTime|null
  65.      */
  66.     protected $deletedAt;
  67.     /**
  68.      * Alert constructor.
  69.      */
  70.     public function __construct()
  71.     {
  72.         $this->enabled true;
  73.         $this->translations = new ArrayCollection();
  74.     }
  75.     public function __toString()
  76.     {
  77.         return $this->content;
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getContent(): ?string
  84.     {
  85.         return $this->content;
  86.     }
  87.     public function setContent(string $content): self
  88.     {
  89.         $this->content $content;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return mixed
  94.      */
  95.     public function getContentEn(): ?string
  96.     {
  97.         return $this->contentEn;
  98.     }
  99.     /**
  100.      * @param string|null $contentEn
  101.      *
  102.      * @return $this
  103.      */
  104.     public function setContentEn(?string $contentEn): self
  105.     {
  106.         $this->contentEn $contentEn;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return mixed
  111.      */
  112.     public function getContentCa(): ?string
  113.     {
  114.         return $this->contentCa;
  115.     }
  116.     /**
  117.      * @param string|null $contentCa
  118.      *
  119.      * @return $this
  120.      */
  121.     public function setContentCa(?string $contentCa): self
  122.     {
  123.         $this->contentCa $contentCa;
  124.         return $this;
  125.     }
  126.     public function isEnabled(): ?bool
  127.     {
  128.         return $this->enabled;
  129.     }
  130.     public function setEnabled(bool $active): self
  131.     {
  132.         $this->enabled $active;
  133.         return $this;
  134.     }
  135.     /**
  136.      * @Gedmo\Locale
  137.      * Used locale to override Translation listener`s locale
  138.      * this is not a mapped field of entity metadata, just a simple property
  139.      */
  140.     private $locale;
  141.     public function setTranslatableLocale($locale)
  142.     {
  143.         $this->locale $locale;
  144.     }
  145.     public function getTranslations()
  146.     {
  147.         return $this->translations;
  148.     }
  149.     public function addTranslation(AlertTranslation $t)
  150.     {
  151.         if (!$this->translations->contains($t)) {
  152.             $this->translations[] = $t;
  153.             $t->setObject($this);
  154.         }
  155.     }
  156.     /**
  157.      * Set or clear the deleted at timestamp.
  158.      *
  159.      * @return self
  160.      */
  161.     public function setDeletedAt(\DateTime $deletedAt null)
  162.     {
  163.         $this->deletedAt $deletedAt;
  164.         return $this;
  165.     }
  166.     /**
  167.      * Get the deleted at timestamp value. Will return null if
  168.      * the entity has not been soft deleted.
  169.      *
  170.      * @return \DateTime|null
  171.      */
  172.     public function getDeletedAt()
  173.     {
  174.         return $this->deletedAt;
  175.     }
  176. }