<?php
namespace App\Entity\Um6p;
use App\Repository\Um6p\EventRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Utils\Utils;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Symfony\Component\PropertyAccess\PropertyAccess;
/**
* @ORM\Entity(repositoryClass=EventRepository::class)
* @Vich\Uploadable
*/
class Event implements TranslatableInterface
{
use TranslatableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @Assert\NotBlank(message="slug Obligatoire")
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $link;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $location;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $position;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $publier;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $encours;
/**
* @ORM\OneToMany(targetEntity=BlockEvent::class, mappedBy="event", cascade={"persist","remove"})
* @ORM\OrderBy({"position" = "ASC"})
*/
private $blocks;
/**
* @ORM\OneToMany(targetEntity=MediaEvent::class, mappedBy="event", cascade={"persist","remove"})
* @ORM\OrderBy({"position" = "ASC"})
*/
private $medias;
/**
* @ORM\ManyToMany(targetEntity=Speaker::class, inversedBy="events")
* @ORM\OrderBy({"position" = "ASC"})
*/
private $speakers;
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="datetime", nullable=true)
*/
private $created_at;
/**
* @Gedmo\Timestampable(on="update")
* @ORM\Column(type="datetime", nullable=true)
*/
private $updated_at;
/**
* @Vich\UploadableField(mapping="event_image", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $datePublier;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_final;
protected $translations;
public function __toString(){
return $this->getTitre();
}
public function getDtitre(){
return $this->getTitre();
}
public function __construct()
{
$this->blocks = new ArrayCollection();
$this->medias = new ArrayCollection();
$this->speakers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getLink(): ?string
{
return $this->link;
}
public function setLink(?string $link): self
{
$this->link = $link;
return $this;
}
public function getLocation(): ?string
{
return $this->location;
}
public function setLocation(?string $location): self
{
$this->location = $location;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
public function isPublier(): ?bool
{
return $this->publier;
}
public function setPublier(?bool $publier): self
{
$this->publier = $publier;
return $this;
}
public function isEncours(): ?bool
{
return $this->encours;
}
public function setEncours(?bool $encours): self
{
$this->encours = $encours;
return $this;
}
/**
* @return Collection|BlockEvent[]
*/
public function getBlocks(): Collection
{
return $this->blocks;
}
public function addBlock(BlockEvent $block): self
{
if (!$this->blocks->contains($block)) {
$this->blocks[] = $block;
$block->setEvent($this);
}
return $this;
}
public function removeBlock(BlockEvent $block): self
{
if ($this->blocks->removeElement($block)) {
// set the owning side to null (unless already changed)
if ($block->getEvent() === $this) {
$block->setEvent(null);
}
}
return $this;
}
/**
* @return Collection|MediaEvent[]
*/
public function getMedias(): Collection
{
return $this->medias;
}
public function addMedia(MediaEvent $media): self
{
if (!$this->medias->contains($media)) {
$this->medias[] = $media;
$media->setEvent($this);
}
return $this;
}
public function removeMedia(MediaEvent $media): self
{
if ($this->medias->removeElement($media)) {
if ($media->getEvent() === $this) {
$media->setEvent(null);
}
}
return $this;
}
/**
* @return Collection|Speaker[]
*/
public function getSpeakers(): Collection
{
return $this->speakers;
}
public function addSpeaker(Speaker $speaker): self
{
if (!$this->speakers->contains($speaker)) {
$this->speakers[] = $speaker;
$speaker->addElement($this);
}
return $this;
}
public function removeSpeaker(Speaker $speaker): self
{
if ($this->speakers->removeElement($speaker)) {
$speaker->removeElement($this);
}
return $this;
}
public function setImageFile(?File $image = null)
{
$this->imageFile = $image;
if ($image) {
$this->updated_at = new \DateTime('now');
}
return $this;
}
public function getImageFile()
{
return $this->imageFile;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getDatePublier(): ?\DateTimeInterface
{
return $this->datePublier;
}
public function setDatePublier(?\DateTimeInterface $datePublier): self
{
$this->datePublier = $datePublier;
return $this;
}
public function getDateFinal(): ?\DateTimeInterface
{
return $this->date_final;
}
public function setDateFinal(?\DateTimeInterface $date_final): self
{
$this->date_final = $date_final;
return $this;
}
public function getDateFormat($local="en")
{
return Utils::getDateFormatingsansday($this->date_final->format('Y-m-d'),$local);
}
public function __call($method, $arguments)
{
return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
}
}