<?php
namespace App\Entity;
use App\Repository\CategorypageRepository;
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 Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Symfony\Component\PropertyAccess\PropertyAccess;
/**
* @ORM\Entity(repositoryClass=CategorypageRepository::class)
* @Vich\Uploadable
* @UniqueEntity(
* fields={"slug"},
* message="Catégorie deja Exist."
* )
*/
class Categorypage implements TranslatableInterface
{
use TranslatableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $position;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
/**
* @ORM\OneToMany(targetEntity=Page::class, mappedBy="categorie")
* @ORM\OrderBy({"position" = "ASC"})
*/
private $pages;
/**
* @Vich\UploadableField(mapping="category_image", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @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="string", length=255, nullable=true)
*/
private $imagemobile;
/**
* @Vich\UploadableField(mapping="category_image", fileNameProperty="imagemobile")
* @var File
*/
private $imagemobileFile;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $menu;
protected $translations;
public function __construct()
{
$this->pages = new ArrayCollection();
}
public function __toString(){
return $this->getTitre();
}
public function getDtitre(){
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 getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection|Page[]
*/
public function getPages(): Collection
{
return $this->pages;
}
public function addPage(Page $page): self
{
if (!$this->pages->contains($page)) {
$this->pages[] = $page;
$page->setCategorie($this);
}
return $this;
}
public function removePage(Page $page): self
{
if ($this->pages->removeElement($page)) {
// set the owning side to null (unless already changed)
if ($page->getCategorie() === $this) {
$page->setCategorie(null);
}
}
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 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;
}
public function __call($method, $arguments)
{
return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
}
}