<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\PageRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Translation\PageTranslation;
use Gedmo\Translatable\Translatable;
use Gedmo\Mapping\Annotation\TranslationEntity;
use Gedmo\Mapping\Annotation\Locale as GedmoLocale;
use Gedmo\Mapping\Annotation\Translatable as GedmoTranslatable;
#[ORM\Entity(repositoryClass: PageRepository::class)]
#[TranslationEntity(class: PageTranslation::class)]
class Page implements Translatable, EntityInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $type = 'page';
#[ORM\Column(type: 'integer')]
private $page = 0;
#[ORM\Column(type: 'string', length: 255)]
private $intname = '';
#[ORM\Column(type: 'boolean')]
private $mainpage = false;
#[GedmoTranslatable]
#[ORM\Column(type: 'string', length: 255)]
private $name = '';
#[ORM\Column(type: 'string', length: 255)]
private $href = '';
#[GedmoTranslatable]
#[ORM\Column(type: 'text')]
private $short = '';
#[GedmoTranslatable]
#[ORM\Column(type: 'text')]
private $cont = '';
private $cont2 = '';
#[ORM\Column(type: 'smallint')]
private $prior = 0;
#[ORM\Column(type: 'boolean')]
private $visible = 1;
#[GedmoTranslatable]
#[ORM\Column(type: 'string', length: 255)]
private $title = '';
#[GedmoTranslatable]
#[ORM\Column(type: 'string', length: 255)]
private $h1 = '';
#[GedmoTranslatable]
#[ORM\Column(type: 'string', length: 255)]
private $kw = '';
#[GedmoTranslatable]
#[ORM\Column(type: 'string', length: 1000)]
private $descr = '';
#[ORM\Column(type: 'integer')]
private $tstamp = 0;
#[ORM\Column(type: 'string', length: 255)]
private $icon = '';
#[ORM\OneToMany(mappedBy: 'page', targetEntity: PagePhoto::class)]
private $photos;
#[ORM\OneToMany(mappedBy: 'page', targetEntity: PageBlock::class)]
private $blocks;
#[GedmoLocale]
private $locale;
#[ORM\OneToMany(targetEntity: PageTranslation::class, mappedBy: 'object', cascade: ['persist', 'remove'])]
private $translations;
public function __construct()
{
$this->photos = new ArrayCollection();
$this->blocks = new ArrayCollection();
$this->translations = new ArrayCollection();
}
public function setLocale($locale)
{
$this->locale = $locale;
}
public function getTranslations()
{
return $this->translations;
}
public function addTranslation(PageTranslation $t)
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
}
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getPage(): ?int
{
return $this->page;
}
public function setPage(int $page): self
{
$this->page = $page;
return $this;
}
public function getIntname(): ?string
{
return $this->intname;
}
public function setIntname(string $intname): self
{
$this->intname = $intname;
return $this;
}
public function isMainpage(): ?bool
{
return $this->mainpage;
}
public function setMainpage(bool $mainpage): self
{
$this->mainpage = $mainpage;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getHref(): ?string
{
return $this->href;
}
public function setHref(string $href): self
{
$this->href = $href;
return $this;
}
public function getShort(): ?string
{
return $this->short ? $this->short : mb_substr(strip_tags($this->getCont()), 0, 200)."...";
}
public function setShort(string $short): self
{
$this->short = $short;
return $this;
}
public function getCont(): ?string
{
return $this->cont;
}
public function setCont(string $cont): self
{
$this->cont = $cont;
return $this;
}
public function getCont2(): ?string
{
return $this->cont;
}
public function setCont2(string $cont): self
{
$this->cont = $cont;
return $this;
}
public function getPrior(): ?int
{
return $this->prior;
}
public function setPrior(int $prior): self
{
$this->prior = $prior;
return $this;
}
public function isVisible(): ?bool
{
return $this->visible;
}
public function setVisible(bool $visible): self
{
$this->visible = $visible;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getH1(): ?string
{
return $this->h1;
}
public function setH1(string $h1): self
{
$this->h1 = $h1;
return $this;
}
public function getKw(): ?string
{
return $this->kw;
}
public function setKw(string $kw): self
{
$this->kw = $kw;
return $this;
}
public function getDescr(): ?string
{
return $this->descr;
}
public function setDescr(string $descr): self
{
$this->descr = $descr;
return $this;
}
public function getTstamp(): ?int
{
return $this->tstamp;
}
public function setTstamp(int $tstamp): self
{
$this->tstamp = $tstamp;
return $this;
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setIcon(string $icon): self
{
$this->icon = $icon;
return $this;
}
/**
* @return Collection<int, PagePhoto>
*/
public function getPhotos(): Collection
{
return $this->photos;
}
public function addPhoto(PagePhoto $photo): self
{
if (!$this->photos->contains($photo)) {
$this->photos[] = $photo;
$photo->setPage($this);
}
return $this;
}
public function removePhoto(PagePhoto $photo): self
{
if ($this->photos->removeElement($photo)) {
// set the owning side to null (unless already changed)
if ($photo->getPage() === $this) {
$photo->setPage(null);
}
}
return $this;
}
/**
* @return Collection<int, PageBlock>
*/
public function getBlocks(): Collection
{
return $this->blocks;
}
public function addBlock(PageBlock $block): self
{
if (!$this->blocks->contains($block)) {
$this->blocks[] = $block;
$block->setPage($this);
}
return $this;
}
public function removeBlock(PageBlock $block): self
{
if ($this->blocks->removeElement($block)) {
// set the owning side to null (unless already changed)
if ($block->getPage() === $this) {
$block->setPage(null);
}
}
return $this;
}
}