<?php
namespace App\Entity\InformativePills;
use App\Annotation\SiteAware;
use App\Entity\AbstractBase;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\Traits\ActiveTrait;
use App\Entity\Traits\ImageFileNameTrait;
use App\Entity\Traits\ImageFileTrait;
use App\Entity\Traits\PositionTrait;
use App\Entity\Traits\SiteTrait;
use App\Repository\InformativePills\InformativePillRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Table(name="vulco_informative_pill", indexes={@ORM\Index(name="informative_pill_site_idx", columns={"site"})})
* @ORM\Entity(repositoryClass=InformativePillRepository::class)
* @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
* @SiteAware(siteFieldName="site")
* @Vich\Uploadable
*/
class InformativePill extends AbstractBase implements SiteInterface
{
use ActiveTrait;
use ImageFileTrait;
use ImageFileNameTrait;
use PositionTrait;
use SiteTrait;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $title;
/**
* @ORM\Column(type="text", length=10000, nullable=true)
*/
private ?string $videoIframe = null;
/**
* @Vich\UploadableField(mapping="informative_pill_image", fileNameProperty="imageFileName")
*/
private ?File $imageFile = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $imageFileName = null;
/**
* @ORM\Column(type="integer", nullable=false, options={"default": 0})
*/
private int $position = 0;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default": 1})
*/
private bool $active = true;
/**
* @ORM\OneToMany(targetEntity="InformativePillVideoPlayback", mappedBy="informativePill")
* @ORM\OrderBy({"createdAt": "DESC"})
*/
private ?Collection $playbacks;
/**
* @ORM\ManyToOne(targetEntity="InformativePillFamily", inversedBy="informativePills")
*/
private ?InformativePillFamily $family = null;
public function __construct()
{
$this->playbacks = new ArrayCollection();
}
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getVideoIframe(): ?string
{
return $this->videoIframe;
}
public function setVideoIframe(?string $videoIframe): self
{
$this->videoIframe = $videoIframe;
return $this;
}
public function getPlaybacks(): ?Collection
{
return $this->playbacks;
}
public function getPlaybacksAmount(): int
{
$result = 0;
if ($this->getPlaybacks()) {
$result = $this->getPlaybacks()->count();
}
return $result;
}
public function setPlaybacks(?Collection $playbacks): self
{
$this->playbacks = $playbacks;
return $this;
}
public function addPlayback(InformativePillVideoPlayback $playback): self
{
if ($this->getPlaybacks() && !$this->getPlaybacks()->contains($playback)) {
$this->getPlaybacks()->add($playback);
$playback->setInformativePill($this);
}
return $this;
}
public function removePlayback(InformativePillVideoPlayback $playback): self
{
if ($this->getPlaybacks() && $this->getPlaybacks()->contains($playback)) {
$this->getPlaybacks()->removeElement($playback);
}
return $this;
}
public function getFamily(): ?InformativePillFamily
{
return $this->family;
}
public function setFamily(?InformativePillFamily $family): self
{
$this->family = $family;
return $this;
}
}