src/Entity/Streaming.php line 26

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