<?php
namespace App\Entity\SiteHome;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\Model\TranslatableInterface;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Gedmo\Timestampable\Timestampable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Core\Model\ImagesAwareInterface;
use Sylius\Component\Core\Model\ImageInterface;
class Slide implements ResourceInterface, TranslatableInterface, ImagesAwareInterface, Timestampable
{
use TimestampableEntity;
use TranslatableTrait {
__construct as private initializeTranslationsCollection;
}
/**
* @var integer
*/
protected $id;
/**
* @var integer
*/
protected $position;
/**
* @var object
*/
protected $fabricProduct;
/**
* @var array
*/
protected $images;
/**
* @var bool
*/
protected $enabled;
/**
* @var \DateTime
*/
protected $dateDiffusion;
public function __construct()
{
$this->initializeTranslationsCollection();
$this->images = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position)
{
$this->position = $position;
}
public function getFabricProduct()
{
return $this->fabricProduct;
}
public function setFabricProduct($fabricProduct)
{
$this->fabricProduct = $fabricProduct;
}
/**
* {@inheritdoc}
*/
public function getImages(): Collection
{
return $this->images;
}
/**
* {@inheritdoc}
*/
public function getImagesByType(string $type): Collection
{
return $this->images->filter(function (ImageInterface $image) use ($type) {
return $type === $image->getType();
});
}
/**
* {@inheritdoc}
*/
public function hasImages(): bool
{
return !$this->images->isEmpty();
}
/**
* {@inheritdoc}
*/
public function hasImage(ImageInterface $image): bool
{
return $this->images->contains($image);
}
/**
* {@inheritdoc}
*/
public function addImage(ImageInterface $image): void
{
$image->setOwner($this);
$this->images->add($image);
}
/**
* {@inheritdoc}
*/
public function removeImage(ImageInterface $image): void
{
if ($this->hasImage($image)) {
$image->setOwner(null);
$this->images->removeElement($image);
}
}
public function getEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled)
{
$this->enabled = $enabled;
}
public function getTitle(): ?string
{
return $this->getTranslation()->getTitle();
}
public function setTitle(?string $title): void
{
$this->getTranslation()->setTitle($title);
}
public function getSubTitle(): ?string
{
return $this->getTranslation()->getSubTitle();
}
public function setSubTitle(?string $subTitle): void
{
$this->getTranslation()->setSubTitle($subTitle);
}
public function getDescription(): ?string
{
return $this->getTranslation()->getDescription();
}
public function setDescription(?string $description): void
{
$this->getTranslation()->setDescription($description);
}
public function getLinkTitle(): ?string
{
return $this->getTranslation()->getLinkTitle();
}
public function setLinkTitle(?string $linkTitle): void
{
$this->getTranslation()->setLinkTitle($linkTitle);
}
public function getLink(): ?string
{
return $this->getTranslation()->getLink();
}
public function setLink(?string $link): void
{
$this->getTranslation()->setLink($link);
}
protected function createTranslation(): SlideTranslation
{
return new SlideTranslation();
}
public function getDateDiffusion()
{
return $this->dateDiffusion;
}
public function setDateDiffusion($dateDiffusion): void
{
$this->dateDiffusion = $dateDiffusion;
}
}