<?php
namespace App\Entity;
use App\Repository\FreePageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=FreePageRepository::class)
*/
class FreePage implements WithQRCodeInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $roles = [];
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank
* @Assert\Regex(
* pattern="/^[a-z0-9\-]+$/",
* message="Le champ doit-etre composé uniquement de lettres minuscules, chiffres et tirets.")
*/
private $route;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* @ORM\Column(type="integer")
*/
private $position;
/**
* @ORM\OneToMany(targetEntity=FreePageBlock::class, mappedBy="freePage", orphanRemoval=true)
* @ORM\OrderBy({"position" = "ASC"})
*/
private $pageBlocks;
/**
* @ORM\OneToOne(targetEntity=Seo::class, cascade={"persist", "remove"})
*/
private $seo;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $qrCode;
/**
* @ORM\Column(type="boolean")
*/
private $isPublic;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isAccessibleForInternalMembers;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isAccessibleForExternalMembers;
/**
* @ORM\ManyToOne(targetEntity=Instance::class)
*/
#[Assert\NotNull(message: 'L’organisation est obligatoire.')]
private $instance;
public function __construct()
{
$this->pageBlocks = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getRoute(): ?string
{
return $this->route;
}
public function setRoute(?string $route): self
{
$this->route = $route;
return $this;
}
/**
* @return Collection|FreePageBlock[]
*/
public function getPageBlocks(): Collection
{
return $this->pageBlocks;
}
public function addPageBlock(FreePageBlock $pageBlock): self
{
if (!$this->pageBlocks->contains($pageBlock)) {
$this->pageBlocks[] = $pageBlock;
$pageBlock->setFreePage($this);
}
return $this;
}
public function removePageBlock(FreePageBlock $pageBlock): self
{
if ($this->pageBlocks->removeElement($pageBlock)) {
// set the owning side to null (unless already changed)
if ($pageBlock->getFreePage() === $this) {
$pageBlock->setFreePage(null);
}
}
return $this;
}
public function getSeo(): ?Seo
{
return $this->seo;
}
public function setSeo(?Seo $seo): self
{
$this->seo = $seo;
return $this;
}
public function getMetadatas(): ?string
{
return $this->getSeo()?->getMetadatas();
}
public function getQrCode(): ?string
{
return $this->qrCode;
}
public function setQrCode(string $qrCode): self
{
$this->qrCode = $qrCode;
return $this;
}
public function getQrCodeRouteName(): string
{
return 'free_page';
}
public function getQrCodeRouteParams(): array
{
return [
'route' => $this->getRoute(),
];
}
public function getIsPublic(): ?bool
{
return $this->isPublic;
}
public function setIsPublic(bool $isPublic): self
{
$this->isPublic = $isPublic;
return $this;
}
public function getIsAccessibleForInternalMembers(): ?bool
{
return $this->isAccessibleForInternalMembers;
}
public function setIsAccessibleForInternalMembers(bool $isAccessibleForInternalMembers): self
{
$this->isAccessibleForInternalMembers = $isAccessibleForInternalMembers;
return $this;
}
public function getIsAccessibleForExternalMembers(): ?bool
{
return $this->isAccessibleForExternalMembers;
}
public function setIsAccessibleForExternalMembers(bool $isAccessibleForExternalMembers): self
{
$this->isAccessibleForExternalMembers = $isAccessibleForExternalMembers;
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
return $this->roles;
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function getInstance(): ?Instance
{
return $this->instance;
}
public function setInstance(?Instance $instance): self
{
$this->instance = $instance;
return $this;
}
}