<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* @ORM\Entity(repositoryClass="App\Repository\BannerRepository")
*
* @ORM\Table(
* name="banner",
* indexes={
*
* @ORM\Index(columns={"type"}),
* @ORM\Index(columns={"localeId"})
* }
* )
*
* @Assert\Callback("validateDates")
*/
class Banner
{
/**
* @ORM\Id
*
* @ORM\Column(type="bigint")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $alt;
/**
* @ORM\Column(type="string")
*/
protected $image;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $imageMobile;
/**
* @ORM\Column(type="string")
*/
protected $link;
/**
* @ORM\Column(type="string")
*/
protected $type;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $localeId;
/**
* Locale.
*
* @Gedmo\Locale
*/
protected $locale;
/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $priority;
/** @var array */
private $translations;
/**
* @ORM\Column(type="datetime")
*/
private $startDate;
/**
* @ORM\Column(type="datetime")
*/
private $endDate;
public function getId()
{
return $this->id;
}
public function getAlt()
{
return $this->alt;
}
public function setAlt($alt): void
{
$this->alt = $alt;
}
public function getLink()
{
return $this->link;
}
public function setLink($link): void
{
$this->link = $link;
}
public function getImage()
{
return $this->image;
}
public function setImage($image): void
{
$this->image = $image;
}
public function getImageMobile()
{
return $this->imageMobile;
}
public function setImageMobile($imageMobile): void
{
$this->imageMobile = $imageMobile;
}
public function getType()
{
return $this->type;
}
public function setType($type): void
{
$this->type = $type;
}
public function getLocaleId()
{
return $this->localeId;
}
public function setLocaleId($localeId): void
{
$this->localeId = $localeId;
}
public function getLocale()
{
return $this->locale;
}
public function setLocale($locale): void
{
$this->locale = $locale;
}
public function setTranslatableLocale($locale): void
{
$this->locale = $locale;
}
public function setTranslations(array $translations): void
{
$this->translations = $translations;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(\DateTimeInterface $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(\DateTimeInterface $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function getPriority()
{
return $this->priority;
}
public function setPriority($priority): void
{
$this->priority = $priority;
}
public function validateDates(ExecutionContextInterface $context, $payload): void
{
if ($this->startDate >= $this->endDate) {
$context->buildViolation('La date de début doit être inférieure à la date de fin!')
->atPath('startDate')
->addViolation();
}
}
}