src/Entity/Page.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\LinkTrait;
  4. use App\Entity\Traits\MetaTrait;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Entity\Traits\ActiveTrait;
  7. use App\Entity\Traits\DeleteTrait;
  8. use App\Entity\Traits\SubTitleTrait;
  9. use App\Entity\Traits\TranslateTrait;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use App\Entity\Traits\ImageUploadTrait;
  12. use App\Entity\Traits\TitleAndContentTrait;
  13. use Doctrine\Common\Collections\Collection;
  14. use App\Entity\Traits\ThirdImageUploadTrait;
  15. use App\Entity\Traits\SecondImageUploadTrait;
  16. use App\Entity\Interfaces\DefaultLinkedEntity;
  17. use App\Entity\Traits\SortOrderTrait;
  18. use Doctrine\Common\Collections\ArrayCollection;
  19. use Gedmo\Timestampable\Traits\TimestampableEntity;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  22. /**
  23.  * @Gedmo\Loggable
  24.  *
  25.  * @Gedmo\TranslationEntity(class="App\Entity\PageTranslations")
  26.  */
  27. #[UniqueEntity(fields: ['slug'], errorPath'slug'message'A page has already be created with that title.')]
  28. #[ORM\Entity(repositoryClass\App\Repository\PageRepository::class)]
  29. #[ORM\HasLifecycleCallbacks]
  30. #[ORM\Table(name'page')]
  31. class Page implements DefaultLinkedEntity
  32. {
  33.     use TitleAndContentTrait;
  34.     use SubTitleTrait;
  35.     use LinkTrait;
  36.     use MetaTrait;
  37.     use ActiveTrait;
  38.     use DeleteTrait;
  39.     use ImageUploadTrait;
  40.     use SecondImageUploadTrait;
  41.     use ThirdImageUploadTrait;
  42.     use TimestampableEntity;
  43.     use TranslateTrait;
  44.     // use SortOrderTrait;
  45.     /**
  46.      * @var \DateTime
  47.      */
  48.     public $deletedAt;
  49.     public ?string $createdBy null;
  50.     #[ORM\Column(name'components'type'array'nullabletrue)]
  51.     protected array $components = [];
  52.     #[ORM\Column(name'extraUrlsegments'type'array'nullabletrue)]
  53.     protected array $extraUrlsegments = [];
  54.     #[ORM\Column(name'htmlblocks'type'array'nullabletrue)]
  55.     protected array $htmlblocks = [];
  56.     // /**
  57.     //  * @Gedmo\Versioned
  58.     //  */
  59.     // #[ORM\Column(type: 'boolean', nullable: false)]
  60.     // protected bool $featured = false;
  61.     // /**
  62.     //  * @Gedmo\Versioned
  63.     //  */
  64.     // #[ORM\Column(type: 'boolean', nullable: false)]
  65.     // protected bool $footerFeatured = false;
  66.     /*
  67.         SPECIFICALLY OVERRIDING SLUG PROPERTY AS NEEDS
  68.         TO NOT BE CREATED AUTOMATICALLY
  69.     */
  70.     /**
  71.      * @Gedmo\Translatable
  72.      *
  73.      * @Gedmo\Versioned
  74.      */
  75.     #[ORM\Column(length255uniquetrue)]
  76.     private ?string $slug null;
  77.     #[ORM\Id]
  78.     #[ORM\GeneratedValue]
  79.     #[ORM\Column(type'integer')]
  80.     private int $id;
  81.     /**
  82.      * @Gedmo\Translatable
  83.      *
  84.      * @Gedmo\Versioned
  85.      */
  86.     #[Assert\NotBlank(message'The menu title should not be blank')]
  87.     #[ORM\Column(name'navtitle'type'string'length128)]
  88.     private ?string $navtitle null;
  89.     /**
  90.      * @Gedmo\Translatable
  91.      *
  92.      * @Gedmo\Versioned
  93.      */
  94.     #[ORM\Column(name'url'type'string'length128nullabletrue)]
  95.     private ?string $url null;
  96.     #[ORM\Column(name'viewable_from'type'datetime')]
  97.     private ?\DateTimeInterface $viewable_from null;
  98.     #[ORM\ManyToOne(targetEntity\App\Entity\User::class, inversedBy'pagesupdated')]
  99.     #[ORM\JoinColumn(name'update_by'referencedColumnName'id')]
  100.     private $updatedBy;
  101.     #[ORM\ManyToOne(targetEntity'Page')]
  102.     #[ORM\JoinColumn(name'parent'uniquefalsereferencedColumnName'id'nullabletrue)]
  103.     private ?Page $parent null;
  104.     #[Assert\NotBlank(message'You must select a template')]
  105.     #[ORM\ManyToOne(targetEntity\App\Entity\Templates::class, inversedBy'pagetemplate')]
  106.     private ?Templates $template null;
  107.     #[ORM\OneToMany(targetEntity\App\Entity\MenuItems::class, mappedBy'pageId')]
  108.     private ?Collection $menupage;
  109.     #[ORM\ManyToMany(targetEntity\App\Entity\Slider::class, mappedBy'pages')]
  110.     private ?Collection $slider null;
  111.     #[ORM\OneToMany(targetEntity\App\Entity\PagePreview::class, mappedBy'page')]
  112.     private ?Collection $pagePreviews null;
  113.     #[ORM\Column(type'text'nullabletrue)]
  114.     private $content2;
  115.     // #[ORM\Column(type: 'text', nullable: true)]
  116.     // private $excerpt;
  117.     /**
  118.      * Constructor.
  119.      */
  120.     public function __construct()
  121.     {
  122.         $this->menupage = new ArrayCollection();
  123.     }
  124.     /**
  125.      * Get id.
  126.      *
  127.      * @return int
  128.      */
  129.     public function getId()
  130.     {
  131.         return $this->id;
  132.     }
  133.     /**
  134.      * Set navtitle.
  135.      *
  136.      * @param string $navtitle
  137.      *
  138.      * @return Page
  139.      */
  140.     public function setNavtitle($navtitle)
  141.     {
  142.         $this->navtitle $navtitle;
  143.         return $this;
  144.     }
  145.     /**
  146.      * Get navtitle.
  147.      *
  148.      * @return string
  149.      */
  150.     public function getNavtitle()
  151.     {
  152.         return $this->navtitle;
  153.     }
  154.     /**
  155.      * Set url.
  156.      *
  157.      * @param string $url
  158.      *
  159.      * @return Page
  160.      */
  161.     public function setUrl($url)
  162.     {
  163.         $this->url $url;
  164.         return $this;
  165.     }
  166.     /**
  167.      * Get url.
  168.      *
  169.      * @return string
  170.      */
  171.     public function getUrl()
  172.     {
  173.         return $this->url;
  174.     }
  175.     /**
  176.      * Set deletedAt.
  177.      *
  178.      * @param \DateTime|\DateTimeImmutable $deletedAt
  179.      *
  180.      * @return Page
  181.      */
  182.     public function setDeletedAt(\DateTimeInterface $deletedAt)
  183.     {
  184.         $this->deletedAt $deletedAt;
  185.         return $this;
  186.     }
  187.     /**
  188.      * Set createdBy.
  189.      *
  190.      * @param string $createdBy
  191.      *
  192.      * @return Page
  193.      */
  194.     public function setCreatedBy($createdBy)
  195.     {
  196.         $this->createdBy $createdBy;
  197.         return $this;
  198.     }
  199.     /**
  200.      * Get createdBy.
  201.      *
  202.      * @return string
  203.      */
  204.     public function getCreatedBy()
  205.     {
  206.         return $this->createdBy;
  207.     }
  208.     /**
  209.      * Set updatedBy.
  210.      *
  211.      * @param string $updatedBy
  212.      *
  213.      * @return Page
  214.      */
  215.     public function setUpdatedBy($updatedBy)
  216.     {
  217.         $this->updatedBy $updatedBy;
  218.         return $this;
  219.     }
  220.     /**
  221.      * Get updatedBy.
  222.      *
  223.      * @return \App\Entity\User
  224.      */
  225.     public function getUpdatedBy()
  226.     {
  227.         return $this->updatedBy;
  228.     }
  229.     /**
  230.      * Set parent.
  231.      *
  232.      * @return Page
  233.      */
  234.     public function setParent(Page $parent null)
  235.     {
  236.         $this->parent $parent;
  237.         return $this;
  238.     }
  239.     /**
  240.      * Get parent.
  241.      *
  242.      * @return \App\Entity\Page
  243.      */
  244.     public function getParent()
  245.     {
  246.         return $this->parent;
  247.     }
  248.     /**
  249.      * Set template.
  250.      *
  251.      * @return Page
  252.      */
  253.     public function setTemplate(Templates $template null)
  254.     {
  255.         $this->template $template;
  256.         return $this;
  257.     }
  258.     /**
  259.      * Get template.
  260.      *
  261.      * @return \App\Entity\Templates
  262.      */
  263.     public function getTemplate()
  264.     {
  265.         return $this->template;
  266.     }
  267.     /**
  268.      * Set components.
  269.      *
  270.      * @param array $components
  271.      *
  272.      * @return Page
  273.      */
  274.     public function setComponents($components)
  275.     {
  276.         $this->components $components;
  277.         return $this;
  278.     }
  279.     /**
  280.      * Get components.
  281.      *
  282.      * @return array
  283.      */
  284.     public function getComponents()
  285.     {
  286.         return $this->components;
  287.     }
  288.     /**
  289.      * Set extraUrlsegments.
  290.      *
  291.      * @param array $extraUrlsegments
  292.      *
  293.      * @return Page
  294.      */
  295.     public function setExtraUrlsegments($extraUrlsegments)
  296.     {
  297.         $this->extraUrlsegments $extraUrlsegments;
  298.         return $this;
  299.     }
  300.     /**
  301.      * Get extraUrlsegments.
  302.      *
  303.      * @return array
  304.      */
  305.     public function getExtraUrlsegments()
  306.     {
  307.         return $this->extraUrlsegments;
  308.     }
  309.     /**
  310.      * Set viewable_from.
  311.      *
  312.      * @param \DateTime|\DateTimeImmutable $viewableFrom
  313.      *
  314.      * @return Page
  315.      */
  316.     public function setViewableFrom(\DateTimeInterface $viewableFrom)
  317.     {
  318.         $this->viewable_from $viewableFrom;
  319.         return $this;
  320.     }
  321.     /**
  322.      * Get viewable_from.
  323.      *
  324.      * @return \DateTime
  325.      */
  326.     public function getViewableFrom()
  327.     {
  328.         return $this->viewable_from;
  329.     }
  330.     /**
  331.      * Add menupage.
  332.      *
  333.      * @return Page
  334.      */
  335.     public function addMenupage(MenuItems $menupage)
  336.     {
  337.         $this->menupage[] = $menupage;
  338.         return $this;
  339.     }
  340.     /**
  341.      * Remove menupage.
  342.      */
  343.     public function removeMenupage(MenuItems $menupage)
  344.     {
  345.         $this->menupage->removeElement($menupage);
  346.     }
  347.     /**
  348.      * Get menupage.
  349.      *
  350.      * @return \Doctrine\Common\Collections\Collection
  351.      */
  352.     public function getMenupage()
  353.     {
  354.         return $this->menupage;
  355.     }
  356.     /**
  357.      * Add slider.
  358.      *
  359.      * @return Page
  360.      */
  361.     public function addSlider(Slider $slider)
  362.     {
  363.         $this->slider[] = $slider;
  364.         return $this;
  365.     }
  366.     /**
  367.      * Remove slider.
  368.      */
  369.     public function removeSlider(Slider $slider)
  370.     {
  371.         $this->slider->removeElement($slider);
  372.     }
  373.     /**
  374.      * Get slider.
  375.      *
  376.      * @return \Doctrine\Common\Collections\Collection
  377.      */
  378.     public function getSlider()
  379.     {
  380.         return $this->slider;
  381.     }
  382.     /**
  383.      * Set htmlblocks.
  384.      *
  385.      * @param array $htmlblocks
  386.      *
  387.      * @return Page
  388.      */
  389.     public function setHtmlblocks($htmlblocks)
  390.     {
  391.         $this->htmlblocks $htmlblocks;
  392.         return $this;
  393.     }
  394.     /**
  395.      * Get htmlblocks.
  396.      *
  397.      * @return array
  398.      */
  399.     public function getHtmlblocks()
  400.     {
  401.         return $this->htmlblocks;
  402.     }
  403.     // public function isFeatured(): bool
  404.     // {
  405.     //     return $this->featured;
  406.     // }
  407.     // public function setFeatured(bool $featured): void
  408.     // {
  409.     //     $this->featured = $featured;
  410.     // }
  411.     // public function isFooterFeatured(): bool
  412.     // {
  413.     //     return $this->footerFeatured;
  414.     // }
  415.     // public function setFooterFeatured(bool $footerFeatured): void
  416.     // {
  417.     //     $this->footerFeatured = $footerFeatured;
  418.     // }
  419.     /**
  420.      * Add pagePreviews.
  421.      *
  422.      * @return Page
  423.      */
  424.     public function addPagePreview(PagePreview $pagePreviews)
  425.     {
  426.         $this->pagePreviews[] = $pagePreviews;
  427.         return $this;
  428.     }
  429.     /**
  430.      * Remove pagePreviews.
  431.      */
  432.     public function removePagePreview(PagePreview $pagePreviews)
  433.     {
  434.         $this->pagePreviews->removeElement($pagePreviews);
  435.     }
  436.     /**
  437.      * Get pagePreviews.
  438.      *
  439.      * @return ArrayCollection
  440.      */
  441.     public function getPagePreviews()
  442.     {
  443.         return $this->pagePreviews;
  444.     }
  445.     // REQUIRED BY THE META LINKS TRAIT - NOT REALLY NEEDED HERE BUT WHATEVS :)
  446.     public function getLinkedPageId(): int
  447.     {
  448.         return 1;
  449.     }
  450.     public function getContent2(): ?string
  451.     {
  452.         return $this->content2;
  453.     }
  454.     public function setContent2(?string $content2): self
  455.     {
  456.         $this->content2 $content2;
  457.         return $this;
  458.     }
  459.     // public function getExcerpt(): ?string
  460.     // {
  461.     //     return $this->excerpt;
  462.     // }
  463.     // public function setExcerpt(?string $excerpt): self
  464.     // {
  465.     //     $this->excerpt = $excerpt;
  466.     //     return $this;
  467.     // }
  468. }