<?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\ArticleBlockRepository")
*
* @ORM\HasLifecycleCallbacks()
*
* @ORM\Table(indexes={
*
* @ORM\Index(name="article_deleted_idx", columns={"deleted_at"})
* })
*/
class ArticleBlock
{
public const ARTICLE_BLOCK_COLUMN = 'ARTICLE_BLOCK_COLUMN';
public const ARTICLE_BLOCK_MEDIA = 'ARTICLE_BLOCK_MEDIA';
public const ARTICLE_BLOCK_EMBED = 'ARTICLE_BLOCK_EMBED';
public const ARTICLE_BLOCK_ROW = 'ARTICLE_BLOCK_ROW';
public const ARTICLE_BLOCK_HTML = 'ARTICLE_BLOCK_HTML';
public const ARTICLE_BLOCK_ARTICLE = 'ARTICLE_BLOCK_ARTICLE';
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::ARTICLE_BLOCK_HTML;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $data = null;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ArticleBlock", inversedBy="children")
*
* @ORM\JoinColumn(nullable=true)
*/
private $parent;
public function getId(): ?int
{
return $this->id;
}
public function getType()
{
return $this->block_type;
}
public function setType($type)
{
$this->block_type = $type;
return $this;
}
public function getData()
{
return $this->data;
}
public function setData($data)
{
$this->data = $data;
return $this;
}
public function getPosition()
{
return $this->position;
}
public function setPosition($position)
{
$this->position = $position;
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 ArticleBlockController (Controller)
// Target of a OneToMany from Media (Entity)
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Media", inversedBy="article_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\Article", inversedBy="article_blocks")
*
* @ORM\JoinColumn(nullable=true)
*/
private $article;
public function getArticle(): ?Article
{
return $this->article;
}
public function setArticle(?Article $article): self
{
$this->article = $article;
return $this;
}
/**
* @ORM\OneToMany(targetEntity="App\Entity\ArticleBlock", mappedBy="parent")
*/
private $children;
/**
* @return Collection|ArticleBlock[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChildren(self $article_block): self
{
if (!$this->children->contains($article_block)) {
$this->children[] = $article_block;
$article_block->setParent($this);
}
return $this;
}
public function removeChildren(self $article_block): self
{
if ($this->children->contains($article_block)) {
$this->children->removeElement($article_block);
if ($article_block->getParent() === $this) {
$article_block->setParent(null);
}
}
return $this;
}
}