src/Admin/Entity/StdPagesContent.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Admin\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * StdPagesContent
  6.  */
  7. #[ORM\Table(name'std_pages_content')]
  8. #[ORM\Index(name'fk_std_pages_content_std_users'columns: ['created_by'])]
  9. #[ORM\Index(name'fk_std_pages_content_std_users_0'columns: ['updated_by'])]
  10. #[ORM\Index(name'fk_std_pages_content_std_languages'columns: ['language_code'])]
  11. #[ORM\Entity(repositoryClass'App\Admin\Repository\StdPagesContentRepository')]
  12. #[ORM\HasLifecycleCallbacks]
  13. class StdPagesContent
  14. {
  15.     /**
  16.      * @var \StdPages
  17.      */
  18.     #[ORM\JoinColumn(name'page_id'referencedColumnName'id')]
  19.     #[ORM\ManyToOne(targetEntity'StdPages'inversedBy'pagesContent')]
  20.     #[ORM\Id]
  21.     private $pageId;
  22.     /**
  23.      * @var \StdLanguages
  24.      *
  25.      *
  26.      */
  27.     #[ORM\JoinColumn(name'language_code'referencedColumnName'language_code')]
  28.     #[ORM\ManyToOne(targetEntity'StdLanguages')]
  29.     #[ORM\Id]
  30.     private $languageCode;
  31.     /**
  32.      * @var bool
  33.      */
  34.     #[ORM\Column(name'is_active'type'boolean'nullablefalseoptions: ['default' => 1'comment' => 'Flag that indicates if the content is active'])]
  35.     private $isActive '1';
  36.     /**
  37.      * @var \StdUsers
  38.      */
  39.     #[ORM\JoinColumn(name'created_by'referencedColumnName'id')]
  40.     #[ORM\ManyToOne(targetEntity'StdUsers')]
  41.     private $createdBy;
  42.     /**
  43.      * @var \DateTime
  44.      */
  45.     #[ORM\Column(name'created_date'type'datetime'nullablefalseoptions: ['comment' => 'Date and time of the record creation'])]
  46.     private $createdDate;
  47.     /**
  48.      * @var \StdUsers
  49.      */
  50.     #[ORM\JoinColumn(name'updated_by'referencedColumnName'id')]
  51.     #[ORM\ManyToOne(targetEntity'StdUsers')]
  52.     private $updatedBy;
  53.     /**
  54.      * @var \DateTime
  55.      */
  56.     #[ORM\Column(name'updated_date'type'datetime'nullablefalseoptions: ['comment' => 'Date and time the record was last updated'])]
  57.     private $updatedDate;
  58.     /**
  59.      * @var string
  60.      */
  61.     #[ORM\Column(name'title'type'string'length500nullabletrue)]
  62.     private $title;
  63.     /**
  64.      * @var string
  65.      */
  66.     #[ORM\Column(name'url'type'string'length500nullablefalseoptions: ['comment' => 'Url of the page'])]
  67.     private $url;
  68.     /**
  69.      * @var string
  70.      */
  71.     #[ORM\Column(name'meta_title'type'string'length150nullabletrue)]
  72.     private $metaTitle;
  73.     /**
  74.      * @var string
  75.      */
  76.     #[ORM\Column(name'meta_keywords'type'string'length1000nullabletrueoptions: ['comment' => 'Meta keywords of the page'])]
  77.     private $metaKeywords;
  78.     /**
  79.      * @var string
  80.      */
  81.     #[ORM\Column(name'meta_description'type'string'length255nullabletrueoptions: ['comment' => 'Meta description of the page'])]
  82.     private $metaDescription;
  83.     /**
  84.      * @var string
  85.      */
  86.     #[ORM\Column(name'og_title'type'string'length150nullabletrueoptions: ['comment' => 'Open graph title of the page'])]
  87.     private $ogTitle;
  88.     /**
  89.      * @var string
  90.      */
  91.     #[ORM\Column(name'og_image'type'string'length255nullabletrueoptions: ['comment' => 'Open graph link to the image of the page'])]
  92.     private $ogImage;
  93.     /**
  94.      * @var string
  95.      */
  96.     #[ORM\Column(name'og_description'type'string'length300nullabletrue)]
  97.     private $ogDescription;
  98.     /**
  99.      * @var string
  100.      */
  101.     #[ORM\Column(name'og_url'type'string'length255nullabletrueoptions: ['comment' => 'Open graph url of the page'])]
  102.     private $ogUrl;
  103.     /**
  104.      * @var string
  105.      */
  106.     #[ORM\Column(name'canonical_url'type'string'length500nullabletrueoptions: ['comment' => 'Canonical URL'])]
  107.     private $canonicalUrl;
  108.     /**
  109.      * @var string
  110.      */
  111.     #[ORM\Column(name'scripts_head'type'string'nullabletrueoptions: ['comment' => 'Scripts to add to the head of the page'])]
  112.     private $scriptsHead;
  113.     /**
  114.      * @var string
  115.      */
  116.     #[ORM\Column(name'scripts_body'type'string'nullabletrueoptions: ['comment' => 'Scripts to add to the body of the page'])]
  117.     private $scriptsBody;
  118.     /**
  119.      * @var string
  120.      */
  121.     #[ORM\Column(name'scripts_footer'type'string'nullabletrueoptions: ['comment' => 'Scripts to add to the footer of the page'])]
  122.     private $scriptsFooter;
  123.     /**
  124.      * @var json
  125.      */
  126.     #[ORM\Column(name'content'type'json'nullabletrueoptions: ['comment' => 'Content of the page'])]
  127.     private $content = [];
  128.     public function getPageId(): ?StdPages
  129.     {
  130.         return $this->pageId;
  131.     }
  132.     public function setPageId(?StdPages $pageId): self
  133.     {
  134.         $this->pageId $pageId;
  135.         return $this;
  136.     }
  137.     public function getLanguageCode(): ?StdLanguages
  138.     {
  139.         return $this->languageCode;
  140.     }
  141.     public function setLanguageCode(?StdLanguages $languageCode): self
  142.     {
  143.         $this->languageCode $languageCode;
  144.         return $this;
  145.     }
  146.     public function getIsActive(): ?bool
  147.     {
  148.         return $this->isActive;
  149.     }
  150.     public function setIsActive(bool $isActive): self
  151.     {
  152.         $this->isActive $isActive;
  153.         return $this;
  154.     }
  155.     public function getCreatedDate(): ?\DateTimeInterface
  156.     {
  157.         return $this->createdDate;
  158.     }
  159.     public function setCreatedDate(\DateTimeInterface $createdDate): self
  160.     {
  161.         $this->createdDate $createdDate;
  162.         return $this;
  163.     }
  164.     public function getUpdatedDate(): ?\DateTimeInterface
  165.     {
  166.         return $this->updatedDate;
  167.     }
  168.     public function setUpdatedDate(\DateTimeInterface $updatedDate): self
  169.     {
  170.         $this->updatedDate $updatedDate;
  171.         return $this;
  172.     }
  173.     public function getCreatedBy(): ?StdUsers
  174.     {
  175.         return $this->createdBy;
  176.     }
  177.     public function setCreatedBy(?StdUsers $createdBy): self
  178.     {
  179.         $this->createdBy $createdBy;
  180.         return $this;
  181.     }
  182.     public function getUpdatedBy(): ?StdUsers
  183.     {
  184.         return $this->updatedBy;
  185.     }
  186.     public function setUpdatedBy(?StdUsers $updatedBy): self
  187.     {
  188.         $this->updatedBy $updatedBy;
  189.         return $this;
  190.     }
  191.     public function getTitle(): ?string
  192.     {
  193.         return $this->title;
  194.     }
  195.     public function setTitle(string $title): self
  196.     {
  197.         $this->title $title;
  198.         return $this;
  199.     }
  200.     public function getUrl(): ?string
  201.     {
  202.         return $this->url;
  203.     }
  204.     public function setUrl(string $url): self
  205.     {
  206.         $this->url $url;
  207.         return $this;
  208.     }
  209.     public function getMetaTitle(): ?string
  210.     {
  211.         return $this->metaTitle;
  212.     }
  213.     public function setMetaTitle(?string $metaTitle): self
  214.     {
  215.         $this->metaTitle $metaTitle;
  216.         return $this;
  217.     }
  218.     public function getMetaKeywords(): ?string
  219.     {
  220.         return $this->metaKeywords;
  221.     }
  222.     public function setMetaKeywords(?string $metaKeywords): self
  223.     {
  224.         $this->metaKeywords $metaKeywords;
  225.         return $this;
  226.     }
  227.     public function getMetaDescription(): ?string
  228.     {
  229.         return $this->metaDescription;
  230.     }
  231.     public function setMetaDescription(?string $metaDescription): self
  232.     {
  233.         $this->metaDescription $metaDescription;
  234.         return $this;
  235.     }
  236.     public function getOgTitle(): ?string
  237.     {
  238.         return $this->ogTitle;
  239.     }
  240.     public function setOgTitle(?string $ogTitle): self
  241.     {
  242.         $this->ogTitle $ogTitle;
  243.         return $this;
  244.     }
  245.     public function getOgImage(): ?string
  246.     {
  247.         return $this->ogImage;
  248.     }
  249.     public function setOgImage(?string $ogImage): self
  250.     {
  251.         $this->ogImage $ogImage;
  252.         return $this;
  253.     }
  254.     public function getOgDescription(): ?string
  255.     {
  256.         return $this->ogDescription;
  257.     }
  258.     public function setOgDescription(?string $ogDescription): self
  259.     {
  260.         $this->ogDescription $ogDescription;
  261.         return $this;
  262.     }
  263.     public function getOgUrl(): ?string
  264.     {
  265.         return $this->ogUrl;
  266.     }
  267.     public function setOgUrl(?string $ogUrl): self
  268.     {
  269.         $this->ogUrl $ogUrl;
  270.         return $this;
  271.     }
  272.     public function getCanonicalUrl(): ?string
  273.     {
  274.         return $this->canonicalUrl;
  275.     }
  276.     public function setCanonicalUrl(?string $canonicalUrl): self
  277.     {
  278.         $this->canonicalUrl $canonicalUrl;
  279.         return $this;
  280.     }
  281.     public function getScriptsHead(): ?string
  282.     {
  283.         return $this->scriptsHead;
  284.     }
  285.     public function setScriptsHead(?string $scriptsHead): self
  286.     {
  287.         $this->scriptsHead $scriptsHead;
  288.         return $this;
  289.     }
  290.     public function getScriptsBody(): ?string
  291.     {
  292.         return $this->scriptsBody;
  293.     }
  294.     public function setScriptsBody(?string $scriptsBody): self
  295.     {
  296.         $this->scriptsBody $scriptsBody;
  297.         return $this;
  298.     }
  299.     public function getScriptsFooter(): ?string
  300.     {
  301.         return $this->scriptsFooter;
  302.     }
  303.     public function setScriptsFooter(?string $scriptsFooter): self
  304.     {
  305.         $this->scriptsFooter $scriptsFooter;
  306.         return $this;
  307.     }
  308.     public function getContent(): ?Array
  309.     {
  310.         return $this->content;
  311.     }
  312.     public function setContent(?Array $content): self
  313.     {
  314.         $this->content $content;
  315.         return $this;
  316.     }
  317.      #[ORM\PreUpdate]
  318.     public function setUpdated()
  319.     {
  320.         $this->setUpdatedDate(new \DateTime());
  321.     }
  322.     
  323.     #[ORM\PrePersist]
  324.     public function setCreated()
  325.     {
  326.         $this->setUpdatedDate(new \DateTime());
  327.         $this->setCreatedDate(new \DateTime());
  328.     }
  329.     // --------------------------------------------------
  330.     // Additional helpers for search results normalization
  331.     // --------------------------------------------------
  332.     /**
  333.      * Returns the related content type entity if available.
  334.      */
  335.     public function getContentTypeEntity(): ?StdContentTypes
  336.     {
  337.         return $this->getPageId()?->getContentType();
  338.     }
  339.     /**
  340.      * Returns the raw machine name of the page content type.
  341.      */
  342.     public function getContentTypeMachineName(): ?string
  343.     {
  344.         return $this->getContentTypeEntity()?->getMachineName();
  345.     }
  346.     /**
  347.      * Returns a normalized key used by tabs / counts (news, reportagens, programas, event).
  348.      */
  349.     public function getNormalizedContentTypeKey(): string
  350.     {
  351.         $raw strtolower((string)$this->getContentTypeMachineName());
  352.         if(in_array($raw, ['noticia','noticias','news'], true)) return 'news';
  353.         if(in_array($raw, ['reportagem','reportagens'], true)) return 'reportagens';
  354.         if(in_array($raw, ['programa','programas'], true)) return 'programas';
  355.     if(in_array($raw, ['evento','eventos','event','events'], true)) return 'event';
  356.         // fallback
  357.         return $raw ?: 'news';
  358.     }
  359. }