src/Entity/StaticPageBlock.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\StaticPageBlockRepository")
  8.  *
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class StaticPageBlock
  12. {
  13.     public const STATIC_PAGE_BLOCK_COLUMN 'STATIC_PAGE_BLOCK_COLUMN';
  14.     public const STATIC_PAGE_BLOCK_MEDIA 'STATIC_PAGE_BLOCK_MEDIA';
  15.     public const STATIC_PAGE_BLOCK_EMBED 'STATIC_PAGE_BLOCK_EMBED';
  16.     public const STATIC_PAGE_BLOCK_ROW 'STATIC_PAGE_BLOCK_ROW';
  17.     public const STATIC_PAGE_BLOCK_HTML 'STATIC_PAGE_BLOCK_HTML';
  18.     public const STATIC_PAGE_BLOCK_HEADER 'STATIC_PAGE_BLOCK_HEADER';
  19.     public const STATIC_PAGE_BLOCK_BUTTON 'STATIC_PAGE_BLOCK_BUTTON';
  20.     public function __construct()
  21.     {
  22.         $this->children = new ArrayCollection();
  23.     }
  24.     /**
  25.      * @ORM\Id()
  26.      *
  27.      * @ORM\GeneratedValue()
  28.      *
  29.      * @ORM\Column(type="integer")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\Column(type="integer", nullable=false)
  34.      */
  35.     private $position 0;
  36.     /**
  37.      * @ORM\Column(type="string", length=180, nullable=false)
  38.      */
  39.     private $block_type self::STATIC_PAGE_BLOCK_HTML;
  40.     /**
  41.      * @ORM\Column(type="text", nullable=true)
  42.      */
  43.     private $data null;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity="App\Entity\StaticPageBlock", inversedBy="children")
  46.      *
  47.      * @ORM\JoinColumn(nullable=true)
  48.      */
  49.     private $parent;
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getPosition(): ?int
  55.     {
  56.         return $this->position;
  57.     }
  58.     public function setPosition(int $position): self
  59.     {
  60.         $this->position $position;
  61.         return $this;
  62.     }
  63.     public function getType(): ?string
  64.     {
  65.         return $this->block_type;
  66.     }
  67.     public function setType(string $block_type): self
  68.     {
  69.         $this->block_type $block_type;
  70.         return $this;
  71.     }
  72.     public function getData(): ?string
  73.     {
  74.         return $this->data;
  75.     }
  76.     public function setData(?string $data): self
  77.     {
  78.         $this->data $data;
  79.         return $this;
  80.     }
  81.     public function getParent(): ?self
  82.     {
  83.         return $this->parent;
  84.     }
  85.     public function setParent(?self $parent): self
  86.     {
  87.         $this->parent $parent;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @ORM\Column(type="datetime", nullable=false)
  92.      */
  93.     private $created_at;
  94.     /**
  95.      * @ORM\Column(type="datetime", nullable=true)
  96.      */
  97.     private $updated_at null;
  98.     public function getCreatedAt(): \DateTimeInterface
  99.     {
  100.         return $this->created_at;
  101.     }
  102.     public function setCreatedAt(\DateTimeInterface $created_at): self
  103.     {
  104.         $this->created_at $created_at;
  105.         return $this;
  106.     }
  107.     public function getUpdatedAt(): ?\DateTimeInterface
  108.     {
  109.         return $this->updated_at;
  110.     }
  111.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  112.     {
  113.         $this->updated_at $updated_at;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @ORM\PrePersist
  118.      */
  119.     public function setCreatedAtValue()
  120.     {
  121.         $this->setCreatedAt(new \DateTime());
  122.     }
  123.     /**
  124.      * @ORM\PreUpdate
  125.      */
  126.     public function setUpdatedAtValue()
  127.     {
  128.         $this->setUpdatedAt(new \DateTime());
  129.     }
  130.     /**
  131.      * @ORM\Column(type="datetime", nullable=true)
  132.      */
  133.     private $deleted_at;
  134.     public function getDeletedAt(): ?\DateTimeInterface
  135.     {
  136.         return $this->deleted_at;
  137.     }
  138.     public function setDeletedAt(?\DateTimeInterface $deleted_at): self
  139.     {
  140.         $this->deleted_at $deleted_at;
  141.         return $this;
  142.     }
  143.     // Target of a LinkedEntity from StaticPageBlockController (Controller)
  144.     // Target of a OneToMany from Media (Entity)
  145.     /**
  146.      * @ORM\ManyToOne(targetEntity="App\Entity\Media", inversedBy="static_page_blocks")
  147.      *
  148.      * @ORM\JoinColumn(nullable=true)
  149.      */
  150.     private $media;
  151.     public function getMedia(): ?Media
  152.     {
  153.         return $this->media;
  154.     }
  155.     public function setMedia(?Media $media): self
  156.     {
  157.         $this->media $media;
  158.         return $this;
  159.     }
  160.     // Target of a OneToMany from Article (Entity)
  161.     /**
  162.      * @ORM\ManyToOne(targetEntity="App\Entity\StaticPage", inversedBy="static_page_blocks")
  163.      *
  164.      * @ORM\JoinColumn(nullable=true)
  165.      */
  166.     private $static_page;
  167.     public function getStaticPage(): ?StaticPage
  168.     {
  169.         return $this->static_page;
  170.     }
  171.     public function setStaticPage(?StaticPage $static_page): self
  172.     {
  173.         $this->static_page $static_page;
  174.         return $this;
  175.     }
  176.     /**
  177.      * @ORM\OneToMany(targetEntity="App\Entity\StaticPageBlock", mappedBy="parent")
  178.      */
  179.     private $children;
  180.     /**
  181.      * @return Collection|StaticPageBlock[]
  182.      */
  183.     public function getChildren(): Collection
  184.     {
  185.         return $this->children;
  186.     }
  187.     public function addChildren(self $static_page_block): self
  188.     {
  189.         if (!$this->children->contains($static_page_block)) {
  190.             $this->children[] = $static_page_block;
  191.             $static_page_block->setParent($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeChildren(self $static_page_block): self
  196.     {
  197.         if ($this->children->contains($static_page_block)) {
  198.             $this->children->removeElement($static_page_block);
  199.             if ($static_page_block->getParent() === $this) {
  200.                 $static_page_block->setParent(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205. }