<?php
namespace App\Admin\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* StdPagesContent
*/
#[ORM\Table(name: 'std_pages_content')]
#[ORM\Index(name: 'fk_std_pages_content_std_users', columns: ['created_by'])]
#[ORM\Index(name: 'fk_std_pages_content_std_users_0', columns: ['updated_by'])]
#[ORM\Index(name: 'fk_std_pages_content_std_languages', columns: ['language_code'])]
#[ORM\Entity(repositoryClass: 'App\Admin\Repository\StdPagesContentRepository')]
#[ORM\HasLifecycleCallbacks]
class StdPagesContent
{
/**
* @var \StdPages
*/
#[ORM\JoinColumn(name: 'page_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: 'StdPages', inversedBy: 'pagesContent')]
#[ORM\Id]
private $pageId;
/**
* @var \StdLanguages
*
*
*/
#[ORM\JoinColumn(name: 'language_code', referencedColumnName: 'language_code')]
#[ORM\ManyToOne(targetEntity: 'StdLanguages')]
#[ORM\Id]
private $languageCode;
/**
* @var bool
*/
#[ORM\Column(name: 'is_active', type: 'boolean', nullable: false, options: ['default' => 1, 'comment' => 'Flag that indicates if the content is active'])]
private $isActive = '1';
/**
* @var \StdUsers
*/
#[ORM\JoinColumn(name: 'created_by', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: 'StdUsers')]
private $createdBy;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'created_date', type: 'datetime', nullable: false, options: ['comment' => 'Date and time of the record creation'])]
private $createdDate;
/**
* @var \StdUsers
*/
#[ORM\JoinColumn(name: 'updated_by', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: 'StdUsers')]
private $updatedBy;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'updated_date', type: 'datetime', nullable: false, options: ['comment' => 'Date and time the record was last updated'])]
private $updatedDate;
/**
* @var string
*/
#[ORM\Column(name: 'title', type: 'string', length: 500, nullable: true)]
private $title;
/**
* @var string
*/
#[ORM\Column(name: 'url', type: 'string', length: 500, nullable: false, options: ['comment' => 'Url of the page'])]
private $url;
/**
* @var string
*/
#[ORM\Column(name: 'meta_title', type: 'string', length: 150, nullable: true)]
private $metaTitle;
/**
* @var string
*/
#[ORM\Column(name: 'meta_keywords', type: 'string', length: 1000, nullable: true, options: ['comment' => 'Meta keywords of the page'])]
private $metaKeywords;
/**
* @var string
*/
#[ORM\Column(name: 'meta_description', type: 'string', length: 255, nullable: true, options: ['comment' => 'Meta description of the page'])]
private $metaDescription;
/**
* @var string
*/
#[ORM\Column(name: 'og_title', type: 'string', length: 150, nullable: true, options: ['comment' => 'Open graph title of the page'])]
private $ogTitle;
/**
* @var string
*/
#[ORM\Column(name: 'og_image', type: 'string', length: 255, nullable: true, options: ['comment' => 'Open graph link to the image of the page'])]
private $ogImage;
/**
* @var string
*/
#[ORM\Column(name: 'og_description', type: 'string', length: 300, nullable: true)]
private $ogDescription;
/**
* @var string
*/
#[ORM\Column(name: 'og_url', type: 'string', length: 255, nullable: true, options: ['comment' => 'Open graph url of the page'])]
private $ogUrl;
/**
* @var string
*/
#[ORM\Column(name: 'canonical_url', type: 'string', length: 500, nullable: true, options: ['comment' => 'Canonical URL'])]
private $canonicalUrl;
/**
* @var string
*/
#[ORM\Column(name: 'scripts_head', type: 'string', nullable: true, options: ['comment' => 'Scripts to add to the head of the page'])]
private $scriptsHead;
/**
* @var string
*/
#[ORM\Column(name: 'scripts_body', type: 'string', nullable: true, options: ['comment' => 'Scripts to add to the body of the page'])]
private $scriptsBody;
/**
* @var string
*/
#[ORM\Column(name: 'scripts_footer', type: 'string', nullable: true, options: ['comment' => 'Scripts to add to the footer of the page'])]
private $scriptsFooter;
/**
* @var json
*/
#[ORM\Column(name: 'content', type: 'json', nullable: true, options: ['comment' => 'Content of the page'])]
private $content = [];
public function getPageId(): ?StdPages
{
return $this->pageId;
}
public function setPageId(?StdPages $pageId): self
{
$this->pageId = $pageId;
return $this;
}
public function getLanguageCode(): ?StdLanguages
{
return $this->languageCode;
}
public function setLanguageCode(?StdLanguages $languageCode): self
{
$this->languageCode = $languageCode;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function setCreatedDate(\DateTimeInterface $createdDate): self
{
$this->createdDate = $createdDate;
return $this;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function setUpdatedDate(\DateTimeInterface $updatedDate): self
{
$this->updatedDate = $updatedDate;
return $this;
}
public function getCreatedBy(): ?StdUsers
{
return $this->createdBy;
}
public function setCreatedBy(?StdUsers $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getUpdatedBy(): ?StdUsers
{
return $this->updatedBy;
}
public function setUpdatedBy(?StdUsers $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
public function getMetaTitle(): ?string
{
return $this->metaTitle;
}
public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;
return $this;
}
public function getMetaKeywords(): ?string
{
return $this->metaKeywords;
}
public function setMetaKeywords(?string $metaKeywords): self
{
$this->metaKeywords = $metaKeywords;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getOgTitle(): ?string
{
return $this->ogTitle;
}
public function setOgTitle(?string $ogTitle): self
{
$this->ogTitle = $ogTitle;
return $this;
}
public function getOgImage(): ?string
{
return $this->ogImage;
}
public function setOgImage(?string $ogImage): self
{
$this->ogImage = $ogImage;
return $this;
}
public function getOgDescription(): ?string
{
return $this->ogDescription;
}
public function setOgDescription(?string $ogDescription): self
{
$this->ogDescription = $ogDescription;
return $this;
}
public function getOgUrl(): ?string
{
return $this->ogUrl;
}
public function setOgUrl(?string $ogUrl): self
{
$this->ogUrl = $ogUrl;
return $this;
}
public function getCanonicalUrl(): ?string
{
return $this->canonicalUrl;
}
public function setCanonicalUrl(?string $canonicalUrl): self
{
$this->canonicalUrl = $canonicalUrl;
return $this;
}
public function getScriptsHead(): ?string
{
return $this->scriptsHead;
}
public function setScriptsHead(?string $scriptsHead): self
{
$this->scriptsHead = $scriptsHead;
return $this;
}
public function getScriptsBody(): ?string
{
return $this->scriptsBody;
}
public function setScriptsBody(?string $scriptsBody): self
{
$this->scriptsBody = $scriptsBody;
return $this;
}
public function getScriptsFooter(): ?string
{
return $this->scriptsFooter;
}
public function setScriptsFooter(?string $scriptsFooter): self
{
$this->scriptsFooter = $scriptsFooter;
return $this;
}
public function getContent(): ?Array
{
return $this->content;
}
public function setContent(?Array $content): self
{
$this->content = $content;
return $this;
}
#[ORM\PreUpdate]
public function setUpdated()
{
$this->setUpdatedDate(new \DateTime());
}
#[ORM\PrePersist]
public function setCreated()
{
$this->setUpdatedDate(new \DateTime());
$this->setCreatedDate(new \DateTime());
}
// --------------------------------------------------
// Additional helpers for search results normalization
// --------------------------------------------------
/**
* Returns the related content type entity if available.
*/
public function getContentTypeEntity(): ?StdContentTypes
{
return $this->getPageId()?->getContentType();
}
/**
* Returns the raw machine name of the page content type.
*/
public function getContentTypeMachineName(): ?string
{
return $this->getContentTypeEntity()?->getMachineName();
}
/**
* Returns a normalized key used by tabs / counts (news, reportagens, programas, event).
*/
public function getNormalizedContentTypeKey(): string
{
$raw = strtolower((string)$this->getContentTypeMachineName());
if(in_array($raw, ['noticia','noticias','news'], true)) return 'news';
if(in_array($raw, ['reportagem','reportagens'], true)) return 'reportagens';
if(in_array($raw, ['programa','programas'], true)) return 'programas';
if(in_array($raw, ['evento','eventos','event','events'], true)) return 'event';
// fallback
return $raw ?: 'news';
}
}