src/Entity/SEO/PageMetadata.php line 17

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by simpson <simpsonwork@gmail.com>
  4.  * Date: 2019-03-28
  5.  * Time: 16:24
  6.  */
  7. namespace App\Entity\SEO;
  8. use AngelGamez\TranslatableBundle\Entity\TranslatableValue;
  9. use App\Entity\Location\City;
  10. use App\Repository\PageMetadataRepository;
  11. use Doctrine\ORM\Mapping as ORM;
  12. #[ORM\Table(name: 'page_seo_texts')]
  13. #[ORM\Entity(repositoryClass: PageMetadataRepository::class)]
  14. class PageMetadata
  15. {
  16.     const PAGE_REQUEST_ATTRIBUTE = '_page_seo';
  17.     const FALLBACK_REQUEST_ATTRIBUTE = '_page_seo.fallback';
  18.     #[ORM\Id]
  19.     #[ORM\Column(name: 'id', type: 'integer')]
  20.     #[ORM\GeneratedValue(strategy: 'AUTO')]
  21.     protected int $id;
  22.     #[ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id')]
  23.     #[ORM\ManyToOne(targetEntity: City::class)]
  24.     protected ?City $city = null;
  25.     #[ORM\Column(name: 'uri', type: 'string', unique: true)]
  26.     protected ?string $uri = null;
  27.     #[ORM\Column(name: 'top_html', type: 'translatable', nullable: true)]
  28.     protected ?TranslatableValue $topHtml = null;
  29.     #[ORM\Column(name: 'bottom_html', type: 'translatable', nullable: true)]
  30.     protected ?TranslatableValue $bottomHtml = null;
  31.     #[ORM\Column(name: 'meta_title', type: 'translatable', nullable: true)]
  32.     protected ?TranslatableValue $metaTitle = null;
  33.     #[ORM\Column(name: 'meta_description', type: 'translatable', nullable: true)]
  34.     protected ?TranslatableValue $metaDescription = null;
  35.     #[ORM\Column(name: 'meta_keywords', type: 'translatable', nullable: true)]
  36.     protected ?TranslatableValue $metaKeywords = null;
  37.     #[ORM\Column(name: 'page_heading', type: 'translatable', nullable: true)]
  38.     protected ?TranslatableValue $pageHeading = null;
  39.     public static function create(City $city, string $uri, ?TranslatableValue $topHtml, ?TranslatableValue $bottomHtml, ?TranslatableValue $metaTitle, ?TranslatableValue $metaDescription, ?TranslatableValue $metaKeywords, ?TranslatableValue $pageHeading): self
  40.     {
  41.         $page = new static();
  42.         $page->city = $city;
  43.         $page->uri = $uri;
  44.         $page->update($topHtml, $bottomHtml, $metaTitle, $metaDescription, $metaKeywords, $pageHeading);
  45.         return $page;
  46.     }
  47.     public function update(?TranslatableValue $topHtml, ?TranslatableValue $bottomHtml, ?TranslatableValue $metaTitle, ?TranslatableValue $metaDescription, ?TranslatableValue $metaKeywords, ?TranslatableValue $pageHeading): void
  48.     {
  49.         if ($topHtml) {
  50.             $this->topHtml = $topHtml;
  51.         }
  52.         if ($bottomHtml) {
  53.             $this->bottomHtml = $bottomHtml;
  54.         }
  55.         if ($metaTitle) {
  56.             $this->metaTitle = $metaTitle;
  57.         }
  58.         if ($metaDescription) {
  59.             $this->metaDescription = $metaDescription;
  60.         }
  61.         if ($metaKeywords) {
  62.             $this->metaKeywords = $metaKeywords;
  63.         }
  64.         if ($pageHeading) {
  65.             $this->pageHeading = $pageHeading;
  66.         }
  67.     }
  68.     public function getId(): int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getCity(): ?City
  73.     {
  74.         return $this->city;
  75.     }
  76.     public function getUri(): ?string
  77.     {
  78.         return $this->uri;
  79.     }
  80.     public function getTopHtml(): ?TranslatableValue
  81.     {
  82.         return $this->topHtml;
  83.     }
  84.     public function hasTopHtml(): bool
  85.     {
  86.         return null !== $this->topHtml;
  87.     }
  88.     public function getBottomHtml(): ?TranslatableValue
  89.     {
  90.         return $this->bottomHtml;
  91.     }
  92.     public function hasBottomHtml(): bool
  93.     {
  94.         return null !== $this->bottomHtml;
  95.     }
  96.     public function getMetaTitle(): ?TranslatableValue
  97.     {
  98.         return $this->metaTitle;
  99.     }
  100.     public function hasMetaTitle(): bool
  101.     {
  102.         return null !== $this->metaTitle;
  103.     }
  104.     public function getMetaDescription(): ?TranslatableValue
  105.     {
  106.         return $this->metaDescription;
  107.     }
  108.     public function hasMetaDescription(): bool
  109.     {
  110.         return null !== $this->metaDescription;
  111.     }
  112.     public function getMetaKeywords(): ?TranslatableValue
  113.     {
  114.         return $this->metaKeywords;
  115.     }
  116.     public function hasMetaKeywords(): bool
  117.     {
  118.         return null !== $this->metaKeywords;
  119.     }
  120.     public function getPageHeading(): ?TranslatableValue
  121.     {
  122.         return $this->pageHeading;
  123.     }
  124.     public function hasPageHeading(): bool
  125.     {
  126.         return null !== $this->pageHeading;
  127.     }
  128. }