src/Flexy/FrontBundle/Entity/CategoryPage.php line 16

  1. <?php
  2. namespace App\Flexy\FrontBundle\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\Entity\CategoryPageRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Translatable\Translatable;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. #[ORM\Entity(repositoryClassCategoryPageRepository::class)]
  12. #[ApiResource]
  13. class CategoryPage implements Translatable
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     #[Gedmo\Translatable]
  21.     private ?string $title null;
  22.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  23.     #[Gedmo\Translatable]
  24.     private ?string $description null;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     #[Gedmo\Translatable]
  27.     private ?string $image null;
  28.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  29.     private ?\DateTimeInterface $createdAt null;
  30.     #[ORM\ManyToMany(targetEntityPage::class, mappedBy'categories')]
  31.     private Collection $pages;
  32.     #[Gedmo\Locale]
  33.     private $locale;
  34.     public function __toString()
  35.     {
  36.         return (string) ($this->getTitle() ?? 'New category');
  37.     }
  38.     public function __construct()
  39.     {
  40.         $this->pages = new ArrayCollection();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getTitle(): ?string
  47.     {
  48.         return $this->title;
  49.     }
  50.     public function setTitle(string $title): static
  51.     {
  52.         $this->title $title;
  53.         return $this;
  54.     }
  55.     public function getDescription(): ?string
  56.     {
  57.         return $this->description;
  58.     }
  59.     public function setDescription(?string $description): static
  60.     {
  61.         $this->description $description;
  62.         return $this;
  63.     }
  64.     public function getImage(): ?string
  65.     {
  66.         return $this->image;
  67.     }
  68.     public function setImage(?string $image): static
  69.     {
  70.         $this->image $image;
  71.         return $this;
  72.     }
  73.     public function getCreatedAt(): ?\DateTimeInterface
  74.     {
  75.         return $this->createdAt;
  76.     }
  77.     public function setCreatedAt(?\DateTimeInterface $createdAt): static
  78.     {
  79.         $this->createdAt $createdAt;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, Page>
  84.      */
  85.     public function getPages(): Collection
  86.     {
  87.         return $this->pages;
  88.     }
  89.     public function addPage(Page $page): static
  90.     {
  91.         if (!$this->pages->contains($page)) {
  92.             $this->pages->add($page);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removePage(Page $page): static
  97.     {
  98.         $this->pages->removeElement($page);
  99.         return $this;
  100.     }
  101. }