src/Entity/Categorypage.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategorypageRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  13. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  14. use Symfony\Component\PropertyAccess\PropertyAccess
  15. /**
  16.  * @ORM\Entity(repositoryClass=CategorypageRepository::class)
  17.  * @Vich\Uploadable
  18.  * @UniqueEntity(
  19.  *     fields={"slug"},
  20.  *     message="Catégorie deja Exist."
  21.  * ) 
  22.  */
  23. class Categorypage  implements TranslatableInterface
  24. {
  25.     use TranslatableTrait;
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue
  29.      * @ORM\Column(type="integer")
  30.      */
  31.     private $id
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private $image;
  36.     /**
  37.      * @ORM\Column(type="integer", nullable=true)
  38.      */
  39.     private $position;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, unique=true)
  42.      */
  43.     private $slug;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity=Page::class, mappedBy="categorie")
  46.      * @ORM\OrderBy({"position" = "ASC"})
  47.      */
  48.     private $pages;
  49.     /**
  50.      * @Vich\UploadableField(mapping="category_image", fileNameProperty="image")
  51.      * @var File
  52.      */
  53.     private $imageFile;
  54.     /**
  55.      * @Gedmo\Timestampable(on="create")
  56.      * @ORM\Column(type="datetime", nullable=true)
  57.      */
  58.     private $created_at;
  59.     /**
  60.      * @Gedmo\Timestampable(on="update")
  61.      * @ORM\Column(type="datetime", nullable=true)
  62.      */
  63.     private $updated_at
  64.     /**
  65.      * @ORM\Column(type="string", length=255, nullable=true)
  66.      */
  67.     private $imagemobile;
  68.     /**
  69.      * @Vich\UploadableField(mapping="category_image", fileNameProperty="imagemobile")
  70.      * @var File
  71.      */
  72.     private $imagemobileFile;
  73.     /**
  74.      * @ORM\Column(type="boolean", nullable=true)
  75.      */
  76.     private $menu;
  77.     protected $translations;
  78.     public function __construct()
  79.     {
  80.         $this->pages = new ArrayCollection(); 
  81.     }
  82.     public function __toString(){
  83.         return $this->getTitre();
  84.     }
  85.     public function getDtitre(){
  86.         return $this->getTitre();
  87.     }
  88.     public function getId(): ?int
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function getImage(): ?string
  93.     {
  94.         return $this->image;
  95.     }
  96.     public function setImage(?string $image): self
  97.     {
  98.         $this->image $image;
  99.         return $this;
  100.     }
  101.     public function getPosition(): ?int
  102.     {
  103.         return $this->position;
  104.     }
  105.     public function setPosition(?int $position): self
  106.     {
  107.         $this->position $position;
  108.         return $this;
  109.     }
  110.     public function getSlug(): ?string
  111.     {
  112.         return $this->slug;
  113.     }
  114.     public function setSlug(string $slug): self
  115.     {
  116.         $this->slug $slug;
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return Collection|Page[]
  121.      */
  122.     public function getPages(): Collection
  123.     {
  124.         return $this->pages;
  125.     }
  126.     public function addPage(Page $page): self
  127.     {
  128.         if (!$this->pages->contains($page)) {
  129.             $this->pages[] = $page;
  130.             $page->setCategorie($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removePage(Page $page): self
  135.     {
  136.         if ($this->pages->removeElement($page)) {
  137.             // set the owning side to null (unless already changed)
  138.             if ($page->getCategorie() === $this) {
  139.                 $page->setCategorie(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144.     public function getCreatedAt(): ?\DateTimeInterface
  145.     {
  146.         return $this->created_at;
  147.     }
  148.     public function setCreatedAt(?\DateTimeInterface $created_at): self
  149.     {
  150.         $this->created_at $created_at;
  151.         return $this;
  152.     }
  153.     public function getUpdatedAt(): ?\DateTimeInterface
  154.     {
  155.         return $this->updated_at;
  156.     }
  157.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  158.     {
  159.         $this->updated_at $updated_at;
  160.         return $this;
  161.     }
  162.     public function setImageFile(File $image null)
  163.     {
  164.         $this->imageFile $image;
  165.         if ($image) {
  166.             $this->updated_at = new \DateTime('now');
  167.         }
  168.         return $this;
  169.     }
  170.     public function getImageFile()
  171.     {
  172.         return $this->imageFile;
  173.     }
  174.     public function getImagemobile(): ?string
  175.     {
  176.         return $this->imagemobile;
  177.     }
  178.     public function setImagemobile(?string $imagemobile): self
  179.     {
  180.         $this->imagemobile $imagemobile;
  181.         return $this;
  182.     }
  183.     public function setImagemobileFile(File $image null)
  184.     {
  185.         $this->imagemobileFile $image;
  186.         if ($image) {
  187.             $this->updated_at = new \DateTime('now');
  188.         }
  189.         return $this;
  190.     }
  191.     public function getImagemobileFile()
  192.     {
  193.         return $this->imagemobileFile;
  194.     }
  195.     public function getMenu(): ?bool
  196.     {
  197.         return $this->menu;
  198.     }
  199.     public function setMenu(?bool $menu): self
  200.     {
  201.         $this->menu $menu;
  202.         return $this;
  203.     } 
  204.     public function __call($method$arguments)
  205.     {
  206.         return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
  207.     }
  208. }