<?php
/**
* Created by simpson <simpsonwork@gmail.com>
* Date: 2019-03-28
* Time: 16:24
*/
namespace App\Entity\SEO;
use AngelGamez\TranslatableBundle\Entity\TranslatableValue;
use App\Entity\Location\City;
use App\Repository\PageMetadataRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'page_seo_texts')]
#[ORM\Entity(repositoryClass: PageMetadataRepository::class)]
class PageMetadata
{
const PAGE_REQUEST_ATTRIBUTE = '_page_seo';
const FALLBACK_REQUEST_ATTRIBUTE = '_page_seo.fallback';
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;
#[ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: City::class)]
protected ?City $city = null;
#[ORM\Column(name: 'uri', type: 'string', unique: true)]
protected ?string $uri = null;
#[ORM\Column(name: 'top_html', type: 'translatable', nullable: true)]
protected ?TranslatableValue $topHtml = null;
#[ORM\Column(name: 'bottom_html', type: 'translatable', nullable: true)]
protected ?TranslatableValue $bottomHtml = null;
#[ORM\Column(name: 'meta_title', type: 'translatable', nullable: true)]
protected ?TranslatableValue $metaTitle = null;
#[ORM\Column(name: 'meta_description', type: 'translatable', nullable: true)]
protected ?TranslatableValue $metaDescription = null;
#[ORM\Column(name: 'meta_keywords', type: 'translatable', nullable: true)]
protected ?TranslatableValue $metaKeywords = null;
#[ORM\Column(name: 'page_heading', type: 'translatable', nullable: true)]
protected ?TranslatableValue $pageHeading = null;
public static function create(City $city, string $uri, ?TranslatableValue $topHtml, ?TranslatableValue $bottomHtml, ?TranslatableValue $metaTitle, ?TranslatableValue $metaDescription, ?TranslatableValue $metaKeywords, ?TranslatableValue $pageHeading): self
{
$page = new static();
$page->city = $city;
$page->uri = $uri;
$page->update($topHtml, $bottomHtml, $metaTitle, $metaDescription, $metaKeywords, $pageHeading);
return $page;
}
public function update(?TranslatableValue $topHtml, ?TranslatableValue $bottomHtml, ?TranslatableValue $metaTitle, ?TranslatableValue $metaDescription, ?TranslatableValue $metaKeywords, ?TranslatableValue $pageHeading): void
{
if ($topHtml) {
$this->topHtml = $topHtml;
}
if ($bottomHtml) {
$this->bottomHtml = $bottomHtml;
}
if ($metaTitle) {
$this->metaTitle = $metaTitle;
}
if ($metaDescription) {
$this->metaDescription = $metaDescription;
}
if ($metaKeywords) {
$this->metaKeywords = $metaKeywords;
}
if ($pageHeading) {
$this->pageHeading = $pageHeading;
}
}
public function getId(): int
{
return $this->id;
}
public function getCity(): ?City
{
return $this->city;
}
public function getUri(): ?string
{
return $this->uri;
}
public function getTopHtml(): ?TranslatableValue
{
return $this->topHtml;
}
public function hasTopHtml(): bool
{
return null !== $this->topHtml;
}
public function getBottomHtml(): ?TranslatableValue
{
return $this->bottomHtml;
}
public function hasBottomHtml(): bool
{
return null !== $this->bottomHtml;
}
public function getMetaTitle(): ?TranslatableValue
{
return $this->metaTitle;
}
public function hasMetaTitle(): bool
{
return null !== $this->metaTitle;
}
public function getMetaDescription(): ?TranslatableValue
{
return $this->metaDescription;
}
public function hasMetaDescription(): bool
{
return null !== $this->metaDescription;
}
public function getMetaKeywords(): ?TranslatableValue
{
return $this->metaKeywords;
}
public function hasMetaKeywords(): bool
{
return null !== $this->metaKeywords;
}
public function getPageHeading(): ?TranslatableValue
{
return $this->pageHeading;
}
public function hasPageHeading(): bool
{
return null !== $this->pageHeading;
}
}