src/Entity/Cms.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CmsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClass: CmsRepository::class)]
  9. class Cms
  10. {
  11.     const PAGE = 'Page';
  12.     const BLOCK = 'Block';
  13.             /*'Module',
  14.             'Banner',
  15.             'CTA',
  16.             'Video'*/
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     private ?int $id = null;
  21.     #[ORM\Column(length: 255)]
  22.     private ?string $type = null;
  23.     #[ORM\Column(length: 255)]
  24.     private ?string $title = null;
  25.     #[ORM\Column(length: 255, nullable: true)]
  26.     private ?string $subTitle = null;
  27.     #[ORM\Column(type: Types::TEXT)]
  28.     private ?string $content = null;
  29.     #[ORM\OneToOne(cascade: ['persist', 'remove'])]
  30.     private ?Attachment $background = null;
  31.     #[ORM\OneToOne(cascade: ['persist', 'remove'])]
  32.     private ?Attachment $image = null;
  33.     #[ORM\Column]
  34.     private ?\DateTimeImmutable $createdAt = null;
  35.     #[ORM\Column]
  36.     private ?\DateTimeImmutable $updatedAt = null;
  37.     #[ORM\Column(length: 255)]
  38.     private ?string $direction = null;
  39.     #[ORM\Column]
  40.     private ?bool $isPublic = false;
  41.     #[ORM\ManyToOne(inversedBy: 'cms')]
  42.     private ?User $createdBy = null;
  43.     #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'blocks')]
  44.     private ?self $parent = null;
  45.     #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
  46.     private Collection $blocks;
  47.     #[ORM\Column(length: 255, nullable: true)]
  48.     private ?string $path = null;
  49.     #[ORM\Column(length: 255, nullable: true)]
  50.     private ?string $url = null;
  51.     #[ORM\Column]
  52.     private ?bool $isMenu = false;
  53.     public function __construct()
  54.     {
  55.         if (!$this->createdAt)
  56.             $this->createdAt = new \DateTimeImmutable();
  57.         $this->updatedAt = new \DateTimeImmutable();
  58.         $this->blocks = new ArrayCollection();
  59.     }
  60.     public static function getTypes()
  61.     {
  62.         return [
  63.             self::PAGE,
  64.             'Block',
  65.             'Module',
  66.             'Banner',
  67.             'CTA',
  68.             'Video'
  69.         ];
  70.     }
  71.     public static function getDirections()
  72.     {
  73.         return [
  74.             'none',
  75.             'Left',
  76.             'Right',
  77.             'Top',
  78.             'Bottom',
  79.             'Center',
  80.         ];
  81.     }
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function getType(): ?string
  87.     {
  88.         return $this->type;
  89.     }
  90.     public function setType(string $type): self
  91.     {
  92.         $this->type = $type;
  93.         return $this;
  94.     }
  95.     public function getTitle(): ?string
  96.     {
  97.         return $this->title;
  98.     }
  99.     public function setTitle(string $title): self
  100.     {
  101.         $this->title = $title;
  102.         return $this;
  103.     }
  104.     public function getSubTitle(): ?string
  105.     {
  106.         return $this->subTitle;
  107.     }
  108.     public function setSubTitle(?string $subTitle): self
  109.     {
  110.         $this->subTitle = $subTitle;
  111.         return $this;
  112.     }
  113.     public function getContent(): ?string
  114.     {
  115.         return $this->content;
  116.     }
  117.     public function setContent(string $content): self
  118.     {
  119.         $this->content = $content;
  120.         return $this;
  121.     }
  122.     public function getBackground(): ?Attachment
  123.     {
  124.         return $this->background;
  125.     }
  126.     public function setBackground(?Attachment $background): self
  127.     {
  128.         $this->background = $background;
  129.         return $this;
  130.     }
  131.     public function getImage(): ?Attachment
  132.     {
  133.         return $this->image;
  134.     }
  135.     public function setImage(?Attachment $image): self
  136.     {
  137.         $this->image = $image;
  138.         return $this;
  139.     }
  140.     public function getCreatedAt(): ?\DateTimeImmutable
  141.     {
  142.         return $this->createdAt;
  143.     }
  144.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  145.     {
  146.         $this->createdAt = $createdAt;
  147.         return $this;
  148.     }
  149.     public function getUpdatedAt(): ?\DateTimeImmutable
  150.     {
  151.         return $this->updatedAt;
  152.     }
  153.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  154.     {
  155.         $this->updatedAt = $updatedAt;
  156.         return $this;
  157.     }
  158.     public function getDirection(): ?string
  159.     {
  160.         return $this->direction;
  161.     }
  162.     public function setDirection(string $direction): self
  163.     {
  164.         $this->direction = $direction;
  165.         return $this;
  166.     }
  167.     public function isIsPublic(): ?bool
  168.     {
  169.         return $this->isPublic;
  170.     }
  171.     public function setIsPublic(bool $isPublic): self
  172.     {
  173.         $this->isPublic = $isPublic;
  174.         return $this;
  175.     }
  176.     public function getCreatedBy(): ?User
  177.     {
  178.         return $this->createdBy;
  179.     }
  180.     public function setCreatedBy(?User $createdBy): self
  181.     {
  182.         $this->createdBy = $createdBy;
  183.         return $this;
  184.     }
  185.     public function getParent(): ?self
  186.     {
  187.         return $this->parent;
  188.     }
  189.     public function setParent(?self $parent): self
  190.     {
  191.         $this->parent = $parent;
  192.         return $this;
  193.     }
  194.     /**
  195.      * @return Collection<int, self>
  196.      */
  197.     public function getBlocks(): Collection
  198.     {
  199.         return $this->blocks;
  200.     }
  201.     public function addBlock(self $block): self
  202.     {
  203.         if (!$this->blocks->contains($block)) {
  204.             $this->blocks->add($block);
  205.             $block->setParent($this);
  206.         }
  207.         return $this;
  208.     }
  209.     public function removeBlock(self $block): self
  210.     {
  211.         if ($this->blocks->removeElement($block)) {
  212.             // set the owning side to null (unless already changed)
  213.             if ($block->getParent() === $this) {
  214.                 $block->setParent(null);
  215.             }
  216.         }
  217.         return $this;
  218.     }
  219.     public function getPath(): ?string
  220.     {
  221.         return $this->path;
  222.     }
  223.     public function setPath(?string $path): self
  224.     {
  225.         $this->path = $path;
  226.         return $this;
  227.     }
  228.     public function getUrl(): ?string
  229.     {
  230.         return $this->url;
  231.     }
  232.     public function setUrl(?string $url): self
  233.     {
  234.         $this->url = $url;
  235.         return $this;
  236.     }
  237.     public function isIsMenu(): ?bool
  238.     {
  239.         return $this->isMenu;
  240.     }
  241.     public function setIsMenu(bool $isMenu): self
  242.     {
  243.         $this->isMenu = $isMenu;
  244.         return $this;
  245.     }
  246. }