src/Entity/Page.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PageRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation\Slug;
  9. use Gedmo\Timestampable\Traits\TimestampableEntity;
  10. use Symfony\Component\String\Slugger\AsciiSlugger;
  11. use Symfony\Component\String\Slugger\SluggerInterface;
  12. #[ORM\Entity(repositoryClassPageRepository::class)]
  13. class Page
  14. {
  15.     use TimestampableEntity;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $titre null;
  22.     #[ORM\Column(length255uniquetrue)]
  23.     private ?string $slug null;
  24.     #[ORM\Column(typeTypes::TEXT)]
  25.     private ?string $contenu null;
  26.     #[ORM\Column(typeTypes::TEXT)]
  27.     private ?string $contenuBrut null;
  28.     #[ORM\ManyToMany(targetEntityTarif::class)]
  29.     #[ORM\OrderBy(['rang'=>'ASC'])]
  30.     private Collection $tarifs;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $banniere null;
  33.     #[ORM\OneToMany(mappedBy'page'targetEntitySection::class, cascade: ['persist'], fetch"EAGER"orphanRemovaltrue)]
  34.     private Collection $section;
  35.     #[ORM\Column(typeTypes::SMALLINTnullabletrue)]
  36.     private ?int $template null;
  37.     public function __construct()
  38.     {
  39.         $this->tarifs = new ArrayCollection();
  40.         $this->sliders = new ArrayCollection();
  41.         $this->section = new ArrayCollection();
  42.     }
  43.     public function setId(int $id): self
  44.     {
  45.         $this->id $id;
  46.         return $this;
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getTitre(): ?string
  53.     {
  54.         return $this->titre;
  55.     }
  56.     public function setTitre(string $titre): self
  57.     {
  58.         $this->titre $titre;
  59.         return $this;
  60.     }
  61.     public function getSlug(): ?string
  62.     {
  63.         return $this->slug;
  64.     }
  65.     public function setSlug(string $slug null): self
  66.     {
  67.         if ($slug) {
  68.             $this->slug $slug;
  69.         } else {
  70.             $slug = new AsciiSlugger();
  71.             $this->slug strtolower($slug->slug($this->titre).'.html');
  72.         }
  73.         return $this;
  74.     }
  75.     public function getContenu(): ?string
  76.     {
  77.         return $this->contenu;
  78.     }
  79.     public function setContenu(string $contenu): self
  80.     {
  81.         $this->contenu $contenu;
  82.         return $this;
  83.     }
  84.     public function getContenuBrut(): ?string
  85.     {
  86.         return $this->contenuBrut;
  87.     }
  88.     public function setContenuBrut(string $contenuBrut null): self
  89.     {
  90.         if ($contenuBrut) {
  91.             $this->contenuBrut $contenuBrut;
  92.         } else {
  93.             $this->contenuBrut strip_tags($this->contenu);
  94.         }
  95.         return $this;
  96.     }
  97.     public function getImage(): ?string
  98.     {
  99.         return $this->image;
  100.     }
  101.     public function setImage(?string $image): self
  102.     {
  103.         $this->image $image;
  104.         return $this;
  105.     }
  106.     public function isAccueil() :bool
  107.     {
  108.         if ($this->slug === 'index.html')
  109.         {
  110.             return true;
  111.         }
  112.         return false;
  113.     }
  114.     /**
  115.      * @return Collection<int, Tarif>
  116.      */
  117.     public function getTarifs(): Collection
  118.     {
  119.         return $this->tarifs;
  120.     }
  121.     public function addTarif(Tarif $tarif): self
  122.     {
  123.         if (!$this->tarifs->contains($tarif)) {
  124.             $this->tarifs->add($tarif);
  125.         }
  126.         return $this;
  127.     }
  128.     public function setTarifs(array $tarifs): self
  129.     {
  130.         $this->tarifs = new ArrayCollection();
  131.         foreach ($tarifs as $tarif) {
  132.             $this->tarifs->add($tarif);
  133.         }
  134.         return $this;
  135.     }
  136.     public function removeTarif(Tarif $tarif): self
  137.     {
  138.         $this->tarifs->removeElement($tarif);
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return Collection<int, Slider>
  143.      */
  144.     public function getSliders(): Collection
  145.     {
  146.         return $this->sliders;
  147.     }
  148.     public function addSlider(Slider $slider): self
  149.     {
  150.         if (!$this->sliders->contains($slider)) {
  151.             $this->sliders->add($slider);
  152.             $slider->addPage($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeSlider(Slider $slider): self
  157.     {
  158.         if ($this->sliders->removeElement($slider)) {
  159.             $slider->removePage($this);
  160.         }
  161.         return $this;
  162.     }
  163.     public function getBanniere(): ?string
  164.     {
  165.         return $this->banniere;
  166.     }
  167.     public function setBanniere(?string $banniere): self
  168.     {
  169.         $this->banniere $banniere;
  170.         return $this;
  171.     }
  172.     /**
  173.      * @return Collection<int, Section>
  174.      */
  175.     public function getSection(): Collection
  176.     {
  177.         return $this->section;
  178.     }
  179.     public function addSection(Section $section): self
  180.     {
  181.         if (!$this->section->contains($section)) {
  182.             $this->section->add($section);
  183.             $section->setPage($this);
  184.         }
  185.         return $this;
  186.     }
  187.     public function removeSection(Section $section): self
  188.     {
  189.         if ($this->section->removeElement($section)) {
  190.             // set the owning side to null (unless already changed)
  191.             if ($section->getPage() === $this) {
  192.                 $section->setPage(null);
  193.             }
  194.         }
  195.         return $this;
  196.     }
  197.     public function getTemplate(): ?int
  198.     {
  199.         return $this->template;
  200.     }
  201.     public function setTemplate(?int $template): self
  202.     {
  203.         $this->template $template;
  204.         return $this;
  205.     }
  206. }