<?php
namespace App\Entity;
use App\Entity\Traits\LinkTrait;
use App\Entity\Traits\MetaTrait;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Traits\ActiveTrait;
use App\Entity\Traits\DeleteTrait;
use App\Entity\Traits\SubTitleTrait;
use App\Entity\Traits\TranslateTrait;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Entity\Traits\ImageUploadTrait;
use App\Entity\Traits\TitleAndContentTrait;
use Doctrine\Common\Collections\Collection;
use App\Entity\Traits\ThirdImageUploadTrait;
use App\Entity\Traits\SecondImageUploadTrait;
use App\Entity\Interfaces\DefaultLinkedEntity;
use App\Entity\Traits\SortOrderTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @Gedmo\Loggable
*
* @Gedmo\TranslationEntity(class="App\Entity\PageTranslations")
*/
#[UniqueEntity(fields: ['slug'], errorPath: 'slug', message: 'A page has already be created with that title.')]
#[ORM\Entity(repositoryClass: \App\Repository\PageRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'page')]
class Page implements DefaultLinkedEntity
{
use TitleAndContentTrait;
use SubTitleTrait;
use LinkTrait;
use MetaTrait;
use ActiveTrait;
use DeleteTrait;
use ImageUploadTrait;
use SecondImageUploadTrait;
use ThirdImageUploadTrait;
use TimestampableEntity;
use TranslateTrait;
// use SortOrderTrait;
/**
* @var \DateTime
*/
public $deletedAt;
public ?string $createdBy = null;
#[ORM\Column(name: 'components', type: 'array', nullable: true)]
protected array $components = [];
#[ORM\Column(name: 'extraUrlsegments', type: 'array', nullable: true)]
protected array $extraUrlsegments = [];
#[ORM\Column(name: 'htmlblocks', type: 'array', nullable: true)]
protected array $htmlblocks = [];
// /**
// * @Gedmo\Versioned
// */
// #[ORM\Column(type: 'boolean', nullable: false)]
// protected bool $featured = false;
// /**
// * @Gedmo\Versioned
// */
// #[ORM\Column(type: 'boolean', nullable: false)]
// protected bool $footerFeatured = false;
/*
SPECIFICALLY OVERRIDING SLUG PROPERTY AS NEEDS
TO NOT BE CREATED AUTOMATICALLY
*/
/**
* @Gedmo\Translatable
*
* @Gedmo\Versioned
*/
#[ORM\Column(length: 255, unique: true)]
private ?string $slug = null;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
/**
* @Gedmo\Translatable
*
* @Gedmo\Versioned
*/
#[Assert\NotBlank(message: 'The menu title should not be blank')]
#[ORM\Column(name: 'navtitle', type: 'string', length: 128)]
private ?string $navtitle = null;
/**
* @Gedmo\Translatable
*
* @Gedmo\Versioned
*/
#[ORM\Column(name: 'url', type: 'string', length: 128, nullable: true)]
private ?string $url = null;
#[ORM\Column(name: 'viewable_from', type: 'datetime')]
private ?\DateTimeInterface $viewable_from = null;
#[ORM\ManyToOne(targetEntity: \App\Entity\User::class, inversedBy: 'pagesupdated')]
#[ORM\JoinColumn(name: 'update_by', referencedColumnName: 'id')]
private $updatedBy;
#[ORM\ManyToOne(targetEntity: 'Page')]
#[ORM\JoinColumn(name: 'parent', unique: false, referencedColumnName: 'id', nullable: true)]
private ?Page $parent = null;
#[Assert\NotBlank(message: 'You must select a template')]
#[ORM\ManyToOne(targetEntity: \App\Entity\Templates::class, inversedBy: 'pagetemplate')]
private ?Templates $template = null;
#[ORM\OneToMany(targetEntity: \App\Entity\MenuItems::class, mappedBy: 'pageId')]
private ?Collection $menupage;
#[ORM\ManyToMany(targetEntity: \App\Entity\Slider::class, mappedBy: 'pages')]
private ?Collection $slider = null;
#[ORM\OneToMany(targetEntity: \App\Entity\PagePreview::class, mappedBy: 'page')]
private ?Collection $pagePreviews = null;
#[ORM\Column(type: 'text', nullable: true)]
private $content2;
// #[ORM\Column(type: 'text', nullable: true)]
// private $excerpt;
/**
* Constructor.
*/
public function __construct()
{
$this->menupage = new ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set navtitle.
*
* @param string $navtitle
*
* @return Page
*/
public function setNavtitle($navtitle)
{
$this->navtitle = $navtitle;
return $this;
}
/**
* Get navtitle.
*
* @return string
*/
public function getNavtitle()
{
return $this->navtitle;
}
/**
* Set url.
*
* @param string $url
*
* @return Page
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url.
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set deletedAt.
*
* @param \DateTime|\DateTimeImmutable $deletedAt
*
* @return Page
*/
public function setDeletedAt(\DateTimeInterface $deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Set createdBy.
*
* @param string $createdBy
*
* @return Page
*/
public function setCreatedBy($createdBy)
{
$this->createdBy = $createdBy;
return $this;
}
/**
* Get createdBy.
*
* @return string
*/
public function getCreatedBy()
{
return $this->createdBy;
}
/**
* Set updatedBy.
*
* @param string $updatedBy
*
* @return Page
*/
public function setUpdatedBy($updatedBy)
{
$this->updatedBy = $updatedBy;
return $this;
}
/**
* Get updatedBy.
*
* @return \App\Entity\User
*/
public function getUpdatedBy()
{
return $this->updatedBy;
}
/**
* Set parent.
*
* @return Page
*/
public function setParent(Page $parent = null)
{
$this->parent = $parent;
return $this;
}
/**
* Get parent.
*
* @return \App\Entity\Page
*/
public function getParent()
{
return $this->parent;
}
/**
* Set template.
*
* @return Page
*/
public function setTemplate(Templates $template = null)
{
$this->template = $template;
return $this;
}
/**
* Get template.
*
* @return \App\Entity\Templates
*/
public function getTemplate()
{
return $this->template;
}
/**
* Set components.
*
* @param array $components
*
* @return Page
*/
public function setComponents($components)
{
$this->components = $components;
return $this;
}
/**
* Get components.
*
* @return array
*/
public function getComponents()
{
return $this->components;
}
/**
* Set extraUrlsegments.
*
* @param array $extraUrlsegments
*
* @return Page
*/
public function setExtraUrlsegments($extraUrlsegments)
{
$this->extraUrlsegments = $extraUrlsegments;
return $this;
}
/**
* Get extraUrlsegments.
*
* @return array
*/
public function getExtraUrlsegments()
{
return $this->extraUrlsegments;
}
/**
* Set viewable_from.
*
* @param \DateTime|\DateTimeImmutable $viewableFrom
*
* @return Page
*/
public function setViewableFrom(\DateTimeInterface $viewableFrom)
{
$this->viewable_from = $viewableFrom;
return $this;
}
/**
* Get viewable_from.
*
* @return \DateTime
*/
public function getViewableFrom()
{
return $this->viewable_from;
}
/**
* Add menupage.
*
* @return Page
*/
public function addMenupage(MenuItems $menupage)
{
$this->menupage[] = $menupage;
return $this;
}
/**
* Remove menupage.
*/
public function removeMenupage(MenuItems $menupage)
{
$this->menupage->removeElement($menupage);
}
/**
* Get menupage.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getMenupage()
{
return $this->menupage;
}
/**
* Add slider.
*
* @return Page
*/
public function addSlider(Slider $slider)
{
$this->slider[] = $slider;
return $this;
}
/**
* Remove slider.
*/
public function removeSlider(Slider $slider)
{
$this->slider->removeElement($slider);
}
/**
* Get slider.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSlider()
{
return $this->slider;
}
/**
* Set htmlblocks.
*
* @param array $htmlblocks
*
* @return Page
*/
public function setHtmlblocks($htmlblocks)
{
$this->htmlblocks = $htmlblocks;
return $this;
}
/**
* Get htmlblocks.
*
* @return array
*/
public function getHtmlblocks()
{
return $this->htmlblocks;
}
// public function isFeatured(): bool
// {
// return $this->featured;
// }
// public function setFeatured(bool $featured): void
// {
// $this->featured = $featured;
// }
// public function isFooterFeatured(): bool
// {
// return $this->footerFeatured;
// }
// public function setFooterFeatured(bool $footerFeatured): void
// {
// $this->footerFeatured = $footerFeatured;
// }
/**
* Add pagePreviews.
*
* @return Page
*/
public function addPagePreview(PagePreview $pagePreviews)
{
$this->pagePreviews[] = $pagePreviews;
return $this;
}
/**
* Remove pagePreviews.
*/
public function removePagePreview(PagePreview $pagePreviews)
{
$this->pagePreviews->removeElement($pagePreviews);
}
/**
* Get pagePreviews.
*
* @return ArrayCollection
*/
public function getPagePreviews()
{
return $this->pagePreviews;
}
// REQUIRED BY THE META LINKS TRAIT - NOT REALLY NEEDED HERE BUT WHATEVS :)
public function getLinkedPageId(): int
{
return 1;
}
public function getContent2(): ?string
{
return $this->content2;
}
public function setContent2(?string $content2): self
{
$this->content2 = $content2;
return $this;
}
// public function getExcerpt(): ?string
// {
// return $this->excerpt;
// }
// public function setExcerpt(?string $excerpt): self
// {
// $this->excerpt = $excerpt;
// return $this;
// }
}