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.     public function __construct()
  69.     {
  70.         $this->pageBlocks = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getActive(): ?bool
  77.     {
  78.         return $this->active;
  79.     }
  80.     public function setActive(bool $active): self
  81.     {
  82.         $this->active $active;
  83.         return $this;
  84.     }
  85.     public function getPosition(): ?int
  86.     {
  87.         return $this->position;
  88.     }
  89.     public function setPosition(int $position): self
  90.     {
  91.         $this->position $position;
  92.         return $this;
  93.     }
  94.     public function getTitle(): ?string
  95.     {
  96.         return $this->title;
  97.     }
  98.     public function setTitle(?string $title): self
  99.     {
  100.         $this->title $title;
  101.         return $this;
  102.     }
  103.     public function getRoute(): ?string
  104.     {
  105.         return $this->route;
  106.     }
  107.     public function setRoute(?string $route): self
  108.     {
  109.         $this->route $route;
  110.         return $this;
  111.     }
  112.     /**
  113.      * @return Collection|FreePageBlock[]
  114.      */
  115.     public function getPageBlocks(): Collection
  116.     {
  117.         return $this->pageBlocks;
  118.     }
  119.     public function addPageBlock(FreePageBlock $pageBlock): self
  120.     {
  121.         if (!$this->pageBlocks->contains($pageBlock)) {
  122.             $this->pageBlocks[] = $pageBlock;
  123.             $pageBlock->setFreePage($this);
  124.         }
  125.         return $this;
  126.     }
  127.     public function removePageBlock(FreePageBlock $pageBlock): self
  128.     {
  129.         if ($this->pageBlocks->removeElement($pageBlock)) {
  130.             // set the owning side to null (unless already changed)
  131.             if ($pageBlock->getFreePage() === $this) {
  132.                 $pageBlock->setFreePage(null);
  133.             }
  134.         }
  135.         return $this;
  136.     }
  137.     public function getSeo(): ?Seo
  138.     {
  139.         return $this->seo;
  140.     }
  141.     public function setSeo(?Seo $seo): self
  142.     {
  143.         $this->seo $seo;
  144.         return $this;
  145.     }
  146.     public function getMetadatas(): ?string
  147.     {
  148.         return $this->getSeo()?->getMetadatas();
  149.     }
  150.     public function getQrCode(): ?string
  151.     {
  152.         return $this->qrCode;
  153.     }
  154.     public function setQrCode(string $qrCode): self
  155.     {
  156.         $this->qrCode $qrCode;
  157.         return $this;
  158.     }
  159.     public function getQrCodeRouteName(): string
  160.     {
  161.         return 'free_page';
  162.     }
  163.     public function getQrCodeRouteParams(): array
  164.     {
  165.         return [
  166.             'route' => $this->getRoute(),
  167.         ];
  168.     }
  169.     public function getIsPublic(): ?bool
  170.     {
  171.         return $this->isPublic;
  172.     }
  173.     public function setIsPublic(bool $isPublic): self
  174.     {
  175.         $this->isPublic $isPublic;
  176.         return $this;
  177.     }
  178.     public function getIsAccessibleForInternalMembers(): ?bool
  179.     {
  180.         return $this->isAccessibleForInternalMembers;
  181.     }
  182.     public function setIsAccessibleForInternalMembers(bool $isAccessibleForInternalMembers): self
  183.     {
  184.         $this->isAccessibleForInternalMembers $isAccessibleForInternalMembers;
  185.         return $this;
  186.     }
  187.     public function getIsAccessibleForExternalMembers(): ?bool
  188.     {
  189.         return $this->isAccessibleForExternalMembers;
  190.     }
  191.     public function setIsAccessibleForExternalMembers(bool $isAccessibleForExternalMembers): self
  192.     {
  193.         $this->isAccessibleForExternalMembers $isAccessibleForExternalMembers;
  194.         return $this;
  195.     }
  196.     /**
  197.      * @see UserInterface
  198.      */
  199.     public function getRoles(): array
  200.     {
  201.         return $this->roles;
  202.     }
  203.     public function setRoles(array $roles): self
  204.     {
  205.         $this->roles $roles;
  206.         return $this;
  207.     }
  208. }