src/Entity/InformativePills/InformativePill.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity\InformativePills;
  3. use App\Annotation\SiteAware;
  4. use App\Entity\AbstractBase;
  5. use App\Entity\Interfaces\SiteInterface;
  6. use App\Entity\Traits\ActiveTrait;
  7. use App\Entity\Traits\ImageFileNameTrait;
  8. use App\Entity\Traits\ImageFileTrait;
  9. use App\Entity\Traits\PositionTrait;
  10. use App\Entity\Traits\SiteTrait;
  11. use App\Repository\InformativePills\InformativePillRepository;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Gedmo\Mapping\Annotation as Gedmo;
  16. use Symfony\Component\HttpFoundation\File\File;
  17. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  18. /**
  19.  * @ORM\Table(name="vulco_informative_pill", indexes={@ORM\Index(name="informative_pill_site_idx", columns={"site"})})
  20.  * @ORM\Entity(repositoryClass=InformativePillRepository::class)
  21.  * @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
  22.  * @SiteAware(siteFieldName="site")
  23.  * @Vich\Uploadable
  24.  */
  25. class InformativePill extends AbstractBase implements SiteInterface
  26. {
  27.     use ActiveTrait;
  28.     use ImageFileTrait;
  29.     use ImageFileNameTrait;
  30.     use PositionTrait;
  31.     use SiteTrait;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=false)
  34.      */
  35.     private string $title;
  36.     /**
  37.      * @ORM\Column(type="text", length=10000, nullable=true)
  38.      */
  39.     private ?string $videoIframe null;
  40.     /**
  41.      * @Vich\UploadableField(mapping="informative_pill_image", fileNameProperty="imageFileName")
  42.      */
  43.     private ?File $imageFile null;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private ?string $imageFileName null;
  48.     /**
  49.      * @ORM\Column(type="integer", nullable=false, options={"default": 0})
  50.      */
  51.     private int $position 0;
  52.     /**
  53.      * @ORM\Column(type="boolean", nullable=false, options={"default": 1})
  54.      */
  55.     private bool $active true;
  56.     /**
  57.      * @ORM\OneToMany(targetEntity="InformativePillVideoPlayback", mappedBy="informativePill")
  58.      * @ORM\OrderBy({"createdAt": "DESC"})
  59.      */
  60.     private ?Collection $playbacks;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity="InformativePillFamily", inversedBy="informativePills")
  63.      */
  64.     private ?InformativePillFamily $family null;
  65.     public function __construct()
  66.     {
  67.         $this->playbacks = new ArrayCollection();
  68.     }
  69.     public function getTitle(): string
  70.     {
  71.         return $this->title;
  72.     }
  73.     public function setTitle(string $title): self
  74.     {
  75.         $this->title $title;
  76.         return $this;
  77.     }
  78.     public function getVideoIframe(): ?string
  79.     {
  80.         return $this->videoIframe;
  81.     }
  82.     public function setVideoIframe(?string $videoIframe): self
  83.     {
  84.         $this->videoIframe $videoIframe;
  85.         return $this;
  86.     }
  87.     public function getPlaybacks(): ?Collection
  88.     {
  89.         return $this->playbacks;
  90.     }
  91.     public function getPlaybacksAmount(): int
  92.     {
  93.         $result 0;
  94.         if ($this->getPlaybacks()) {
  95.             $result $this->getPlaybacks()->count();
  96.         }
  97.         return $result;
  98.     }
  99.     public function setPlaybacks(?Collection $playbacks): self
  100.     {
  101.         $this->playbacks $playbacks;
  102.         return $this;
  103.     }
  104.     public function addPlayback(InformativePillVideoPlayback $playback): self
  105.     {
  106.         if ($this->getPlaybacks() && !$this->getPlaybacks()->contains($playback)) {
  107.             $this->getPlaybacks()->add($playback);
  108.             $playback->setInformativePill($this);
  109.         }
  110.         return $this;
  111.     }
  112.     public function removePlayback(InformativePillVideoPlayback $playback): self
  113.     {
  114.         if ($this->getPlaybacks() && $this->getPlaybacks()->contains($playback)) {
  115.             $this->getPlaybacks()->removeElement($playback);
  116.         }
  117.         return $this;
  118.     }
  119.     public function getFamily(): ?InformativePillFamily
  120.     {
  121.         return $this->family;
  122.     }
  123.     public function setFamily(?InformativePillFamily $family): self
  124.     {
  125.         $this->family $family;
  126.         return $this;
  127.     }
  128. }