<?php
namespace App\Entity;
use App\Repository\PageRepository;
use App\Entity\Um6p\Prof;
use Doctrine\Common\Collections\ArrayCollection;
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 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=PageRepository::class)
* @Vich\Uploadable
*/
class Page 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;
/**
* @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;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $publier;
/**
* @Vich\UploadableField(mapping="page_image", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @ORM\ManyToOne(targetEntity=Categorypage::class, inversedBy="pages")
*/
private $categorie;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $position;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $imagemobile;
/**
* @Vich\UploadableField(mapping="page_image", fileNameProperty="imagemobile")
* @var File
*/
private $imagemobileFile;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $menu;
/**
* @ORM\OneToMany(targetEntity=Block::class, mappedBy="page")
* @ORM\OrderBy({"position" = "ASC"})
*/
private $blocks;
protected $translations;
public function __construct()
{
$this->blocks = new ArrayCollection();
}
public function __toString()
{
return $this->getTitre();
}
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 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 getPublier(): ?bool
{
return $this->publier;
}
public function setPublier(?bool $publier): self
{
$this->publier = $publier;
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 getEntity(){
return $this;
}
public function getCategorie(): ?Categorypage
{
return $this->categorie;
}
public function setCategorie(?Categorypage $categorie): self
{
$this->categorie = $categorie;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
public function getImagemobile(): ?string
{
return $this->imagemobile;
}
public function setImagemobile(?string $imagemobile): self
{
$this->imagemobile = $imagemobile;
return $this;
}
public function setImagemobileFile(File $image = null)
{
$this->imagemobileFile = $image;
if ($image) {
$this->updated_at = new \DateTime('now');
}
return $this;
}
public function getImagemobileFile()
{
return $this->imagemobileFile;
}
public function getMenu(): ?bool
{
return $this->menu;
}
public function setMenu(?bool $menu): self
{
$this->menu = $menu;
return $this;
}
/**
* @return Collection|Block[]
*/
public function getBlocks(): Collection
{
return $this->blocks;
}
public function addBlock(Block $block): self
{
if (!$this->blocks->contains($block)) {
$this->blocks[] = $block;
$block->setPage($this);
}
return $this;
}
public function removeBlock(Block $block): self
{
if ($this->blocks->removeElement($block)) {
// set the owning side to null (unless already changed)
if ($block->getPage() === $this) {
$block->setPage(null);
}
}
return $this;
}
public function __call($method, $arguments)
{
return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
}
/* function translate */
public function getDTitre()
{
return $this->getTitre();
}
public function getDpreview()
{
return $this->getPreview();
}
}