<?php
namespace App\Entity;
use App\Repository\ActualitesRepository;
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 Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
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=ActualitesRepository::class)
* @Vich\Uploadable
* @UniqueEntity(
* fields={"slug"},
* message="Actualite deja Exist."
* )
*/
class Actualites implements TranslatableInterface
{
use TranslatableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $datePublier;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @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="image_actualite", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $publier;
protected $translations;
public function __construct()
{
}
public function __toString()
{
return "dddd";
}
public function getId(): ?int
{
return $this->id;
}
public function getDatePublier(): ?\DateTimeInterface
{
return $this->datePublier;
}
public function setDatePublier(?\DateTimeInterface $datePublier): self
{
$this->datePublier = $datePublier;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
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 getPublier(): ?bool
{
return $this->publier;
}
public function setPublier(?bool $publier): self
{
$this->publier = $publier;
return $this;
}
public function getDateFormat($local="fr"){
return Utils::getDateFormating($this->datePublier->format('Y-m-d'),$local);
}
public function __call($method, $arguments)
{
return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
}
}