vendor/contao/core-bundle/src/Routing/ResponseContext/JsonLd/ContaoPageSchema.php line 18

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of Contao.
  5.  *
  6.  * (c) Leo Feyer
  7.  *
  8.  * @license LGPL-3.0-or-later
  9.  */
  10. namespace Contao\CoreBundle\Routing\ResponseContext\JsonLd;
  11. use Contao\CoreBundle\Routing\ResponseContext\HtmlHeadBag\HtmlHeadBag;
  12. use Spatie\SchemaOrg\BaseType;
  13. class ContaoPageSchema extends BaseType
  14. {
  15.     /**
  16.      * ContaoPageSchema constructor.
  17.      *
  18.      * @param array<int> $groups
  19.      */
  20.     public function __construct(string $titleint $pageIdbool $noSearchbool $protected, array $groupsbool $fePreview)
  21.     {
  22.         $this->setTitle($title);
  23.         $this->setPageId($pageId);
  24.         $this->setNoSearch($noSearch);
  25.         $this->setProtected($protected);
  26.         $this->setGroups($groups);
  27.         $this->setFePreview($fePreview);
  28.     }
  29.     public function getContext(): string
  30.     {
  31.         return 'https://schema.contao.org/';
  32.     }
  33.     public function getType(): string
  34.     {
  35.         return 'Page';
  36.     }
  37.     public function getTitle(): string
  38.     {
  39.         return $this->properties['title'];
  40.     }
  41.     public function setTitle(string $title): self
  42.     {
  43.         $this->properties['title'] = $title;
  44.         return $this;
  45.     }
  46.     public function getPageId(): int
  47.     {
  48.         return $this->properties['pageId'];
  49.     }
  50.     public function setPageId(int $pageId): self
  51.     {
  52.         $this->properties['pageId'] = $pageId;
  53.         return $this;
  54.     }
  55.     public function isNoSearch(): bool
  56.     {
  57.         return $this->properties['noSearch'];
  58.     }
  59.     public function setNoSearch(bool $noSearch): self
  60.     {
  61.         $this->properties['noSearch'] = $noSearch;
  62.         return $this;
  63.     }
  64.     public function isProtected(): bool
  65.     {
  66.         return $this->properties['protected'];
  67.     }
  68.     public function setProtected(bool $protected): self
  69.     {
  70.         $this->properties['protected'] = $protected;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return array<int>
  75.      */
  76.     public function getGroups(): array
  77.     {
  78.         return $this->properties['groups'];
  79.     }
  80.     /**
  81.      * @param array<int> $groups
  82.      */
  83.     public function setGroups(array $groups): self
  84.     {
  85.         $this->properties['groups'] = array_map('intval'$groups);
  86.         return $this;
  87.     }
  88.     public function isFePreview(): bool
  89.     {
  90.         return $this->properties['fePreview'];
  91.     }
  92.     public function setFePreview(bool $fePreview): self
  93.     {
  94.         $this->properties['fePreview'] = $fePreview;
  95.         return $this;
  96.     }
  97.     public function updateFromHtmlHeadBag(HtmlHeadBag $bag): self
  98.     {
  99.         return $this->setTitle($bag->getTitle());
  100.     }
  101. }