<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\StaticPageBlockRepository")
*
* @ORM\HasLifecycleCallbacks()
*/
class StaticPageBlock
{
public const STATIC_PAGE_BLOCK_COLUMN = 'STATIC_PAGE_BLOCK_COLUMN';
public const STATIC_PAGE_BLOCK_MEDIA = 'STATIC_PAGE_BLOCK_MEDIA';
public const STATIC_PAGE_BLOCK_EMBED = 'STATIC_PAGE_BLOCK_EMBED';
public const STATIC_PAGE_BLOCK_ROW = 'STATIC_PAGE_BLOCK_ROW';
public const STATIC_PAGE_BLOCK_HTML = 'STATIC_PAGE_BLOCK_HTML';
public const STATIC_PAGE_BLOCK_HEADER = 'STATIC_PAGE_BLOCK_HEADER';
public const STATIC_PAGE_BLOCK_BUTTON = 'STATIC_PAGE_BLOCK_BUTTON';
public function __construct()
{
$this->children = new ArrayCollection();
}
/**
* @ORM\Id()
*
* @ORM\GeneratedValue()
*
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $position = 0;
/**
* @ORM\Column(type="string", length=180, nullable=false)
*/
private $block_type = self::STATIC_PAGE_BLOCK_HTML;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $data = null;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\StaticPageBlock", inversedBy="children")
*
* @ORM\JoinColumn(nullable=true)
*/
private $parent;
public function getId(): ?int
{
return $this->id;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
public function getType(): ?string
{
return $this->block_type;
}
public function setType(string $block_type): self
{
$this->block_type = $block_type;
return $this;
}
public function getData(): ?string
{
return $this->data;
}
public function setData(?string $data): self
{
$this->data = $data;
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private $created_at;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updated_at = null;
public function getCreatedAt(): \DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtValue()
{
$this->setCreatedAt(new \DateTime());
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue()
{
$this->setUpdatedAt(new \DateTime());
}
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $deleted_at;
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deleted_at;
}
public function setDeletedAt(?\DateTimeInterface $deleted_at): self
{
$this->deleted_at = $deleted_at;
return $this;
}
// Target of a LinkedEntity from StaticPageBlockController (Controller)
// Target of a OneToMany from Media (Entity)
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Media", inversedBy="static_page_blocks")
*
* @ORM\JoinColumn(nullable=true)
*/
private $media;
public function getMedia(): ?Media
{
return $this->media;
}
public function setMedia(?Media $media): self
{
$this->media = $media;
return $this;
}
// Target of a OneToMany from Article (Entity)
/**
* @ORM\ManyToOne(targetEntity="App\Entity\StaticPage", inversedBy="static_page_blocks")
*
* @ORM\JoinColumn(nullable=true)
*/
private $static_page;
public function getStaticPage(): ?StaticPage
{
return $this->static_page;
}
public function setStaticPage(?StaticPage $static_page): self
{
$this->static_page = $static_page;
return $this;
}
/**
* @ORM\OneToMany(targetEntity="App\Entity\StaticPageBlock", mappedBy="parent")
*/
private $children;
/**
* @return Collection|StaticPageBlock[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChildren(self $static_page_block): self
{
if (!$this->children->contains($static_page_block)) {
$this->children[] = $static_page_block;
$static_page_block->setParent($this);
}
return $this;
}
public function removeChildren(self $static_page_block): self
{
if ($this->children->contains($static_page_block)) {
$this->children->removeElement($static_page_block);
if ($static_page_block->getParent() === $this) {
$static_page_block->setParent(null);
}
}
return $this;
}
}