src/Entity/FreePage.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FreePageRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=FreePageRepository::class)
  10.  */
  11. class FreePage implements WithQRCodeInterface
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="json", nullable=true)
  21.      */
  22.     private $roles = [];
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      * @Assert\NotBlank
  26.      * @Assert\Regex(
  27.      *  pattern="/^[a-z0-9\-]+$/",
  28.      *  message="Le champ doit-etre composé uniquement de lettres minuscules, chiffres et tirets.")
  29.      */
  30.     private $route;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $title;
  35.     /**
  36.      * @ORM\Column(type="boolean")
  37.      */
  38.     private $active true;
  39.     /**
  40.      * @ORM\Column(type="integer")
  41.      */
  42.     private $position;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity=FreePageBlock::class, mappedBy="freePage", orphanRemoval=true)
  45.      * @ORM\OrderBy({"position" = "ASC"})
  46.      */
  47.     private $pageBlocks;
  48.     /**
  49.      * @ORM\OneToOne(targetEntity=Seo::class, cascade={"persist", "remove"})
  50.      */
  51.     private $seo;
  52.     /**
  53.      * @ORM\Column(type="string", length=255, nullable=true)
  54.      */
  55.     private $qrCode;
  56.     /**
  57.      * @ORM\Column(type="boolean")
  58.      */
  59.     private $isPublic;
  60.     /**
  61.      * @ORM\Column(type="boolean", nullable=true)
  62.      */
  63.     private $isAccessibleForInternalMembers;
  64.     /**
  65.      * @ORM\Column(type="boolean", nullable=true)
  66.      */
  67.     private $isAccessibleForExternalMembers;
  68.     /**
  69.      * @ORM\ManyToOne(targetEntity=Instance::class)
  70.      */
  71.     #[Assert\NotNull(message'L’organisation est obligatoire.')]
  72.     private $instance;
  73.     public function __construct()
  74.     {
  75.         $this->pageBlocks = new ArrayCollection();
  76.     }
  77.     public function getId(): ?int
  78.     {
  79.         return $this->id;
  80.     }
  81.     public function getActive(): ?bool
  82.     {
  83.         return $this->active;
  84.     }
  85.     public function setActive(bool $active): self
  86.     {
  87.         $this->active $active;
  88.         return $this;
  89.     }
  90.     public function getPosition(): ?int
  91.     {
  92.         return $this->position;
  93.     }
  94.     public function setPosition(int $position): self
  95.     {
  96.         $this->position $position;
  97.         return $this;
  98.     }
  99.     public function getTitle(): ?string
  100.     {
  101.         return $this->title;
  102.     }
  103.     public function setTitle(?string $title): self
  104.     {
  105.         $this->title $title;
  106.         return $this;
  107.     }
  108.     public function getRoute(): ?string
  109.     {
  110.         return $this->route;
  111.     }
  112.     public function setRoute(?string $route): self
  113.     {
  114.         $this->route $route;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return Collection|FreePageBlock[]
  119.      */
  120.     public function getPageBlocks(): Collection
  121.     {
  122.         return $this->pageBlocks;
  123.     }
  124.     public function addPageBlock(FreePageBlock $pageBlock): self
  125.     {
  126.         if (!$this->pageBlocks->contains($pageBlock)) {
  127.             $this->pageBlocks[] = $pageBlock;
  128.             $pageBlock->setFreePage($this);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removePageBlock(FreePageBlock $pageBlock): self
  133.     {
  134.         if ($this->pageBlocks->removeElement($pageBlock)) {
  135.             // set the owning side to null (unless already changed)
  136.             if ($pageBlock->getFreePage() === $this) {
  137.                 $pageBlock->setFreePage(null);
  138.             }
  139.         }
  140.         return $this;
  141.     }
  142.     public function getSeo(): ?Seo
  143.     {
  144.         return $this->seo;
  145.     }
  146.     public function setSeo(?Seo $seo): self
  147.     {
  148.         $this->seo $seo;
  149.         return $this;
  150.     }
  151.     public function getMetadatas(): ?string
  152.     {
  153.         return $this->getSeo()?->getMetadatas();
  154.     }
  155.     public function getQrCode(): ?string
  156.     {
  157.         return $this->qrCode;
  158.     }
  159.     public function setQrCode(string $qrCode): self
  160.     {
  161.         $this->qrCode $qrCode;
  162.         return $this;
  163.     }
  164.     public function getQrCodeRouteName(): string
  165.     {
  166.         return 'free_page';
  167.     }
  168.     public function getQrCodeRouteParams(): array
  169.     {
  170.         return [
  171.             'route' => $this->getRoute(),
  172.         ];
  173.     }
  174.     public function getIsPublic(): ?bool
  175.     {
  176.         return $this->isPublic;
  177.     }
  178.     public function setIsPublic(bool $isPublic): self
  179.     {
  180.         $this->isPublic $isPublic;
  181.         return $this;
  182.     }
  183.     public function getIsAccessibleForInternalMembers(): ?bool
  184.     {
  185.         return $this->isAccessibleForInternalMembers;
  186.     }
  187.     public function setIsAccessibleForInternalMembers(bool $isAccessibleForInternalMembers): self
  188.     {
  189.         $this->isAccessibleForInternalMembers $isAccessibleForInternalMembers;
  190.         return $this;
  191.     }
  192.     public function getIsAccessibleForExternalMembers(): ?bool
  193.     {
  194.         return $this->isAccessibleForExternalMembers;
  195.     }
  196.     public function setIsAccessibleForExternalMembers(bool $isAccessibleForExternalMembers): self
  197.     {
  198.         $this->isAccessibleForExternalMembers $isAccessibleForExternalMembers;
  199.         return $this;
  200.     }
  201.     /**
  202.      * @see UserInterface
  203.      */
  204.     public function getRoles(): array
  205.     {
  206.         return $this->roles;
  207.     }
  208.     public function setRoles(array $roles): self
  209.     {
  210.         $this->roles $roles;
  211.         return $this;
  212.     }
  213.     public function getInstance(): ?Instance
  214.     {
  215.         return $this->instance;
  216.     }
  217.     public function setInstance(?Instance $instance): self
  218.     {
  219.         $this->instance $instance;
  220.         return $this;
  221.     }
  222. }