<?php
namespace App\Entity;
use App\Repository\PresseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use App\Utils\Utils;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=PresseRepository::class)
* @Vich\Uploadable
*/
class Presse implements TranslatableInterface
{
use TranslatableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $publier;
/**
* @ORM\Column(type="date")
*/
private $datepublication;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $link;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fichier;
/**
* @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="presse_image", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @Vich\UploadableField(mapping="presse_fichier", fileNameProperty="fichier")
* @var File
*/
private $fichierFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $type_publication;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $type_file;
protected $translations;
public function __construct()
{
}
public function getId(): ?int
{
return $this->id;
}
public function getPublier(): ?bool
{
return $this->publier;
}
public function setPublier(?bool $publier): self
{
$this->publier = $publier;
return $this;
}
public function getDatepublication(): ?\DateTimeInterface
{
return $this->datepublication;
}
public function setDatepublication(\DateTimeInterface $datepublication): self
{
$this->datepublication = $datepublication;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getLink(): ?string
{
return $this->link;
}
public function setLink(?string $link): self
{
$this->link = $link;
return $this;
}
public function getFichier(): ?string
{
return $this->fichier;
}
public function setFichier(?string $fichier): self
{
$this->fichier = $fichier;
return $this;
}
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 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 setFichierFile(File $image = null)
{
$this->fichierFile = $image;
if ($image) {
$this->updated_at = new \DateTime('now');
}
return $this;
}
public function getFichierFile()
{
return $this->fichierFile;
}
public function getTypePublication(): ?string
{
return $this->type_publication;
}
public function setTypePublication(?string $type_publication): self
{
$this->type_publication = $type_publication;
return $this;
}
public function getTypeFile(): ?string
{
return $this->type_file;
}
public function setTypeFile(?string $type_file): self
{
$this->type_file = $type_file;
return $this;
}
public function getDateFormat($local="fr"){
return Utils::getDateFormating($this->datepublication->format('Y-m-d'),$local);
}
public function getDateFormatYear()
{
return $this->datepublication->format('Y');
}
public function __call($method, $arguments)
{
return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
}
}