vendor/shopware/core/Content/Cms/CmsPageEntity.php line 15

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Cms;
  3. use Shopware\Core\Content\Category\CategoryCollection;
  4. use Shopware\Core\Content\Cms\Aggregate\CmsSection\CmsSectionCollection;
  5. use Shopware\Core\Content\Cms\Aggregate\CmsSlot\CmsSlotEntity;
  6. use Shopware\Core\Content\LandingPage\LandingPageCollection;
  7. use Shopware\Core\Content\Media\MediaEntity;
  8. use Shopware\Core\Content\Product\ProductCollection;
  9. use Shopware\Core\Framework\DataAbstractionLayer\Entity;
  10. use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
  11. use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
  12. class CmsPageEntity extends Entity
  13. {
  14.     use EntityIdTrait;
  15.     /**
  16.      * @var string|null
  17.      */
  18.     protected $name;
  19.     /**
  20.      * @var string
  21.      */
  22.     protected $type;
  23.     /**
  24.      * @var string|null
  25.      */
  26.     protected $entity;
  27.     /**
  28.      * @var CmsSectionCollection|null
  29.      */
  30.     protected $sections;
  31.     /**
  32.      * @var EntityCollection|null
  33.      */
  34.     protected $translations;
  35.     /**
  36.      * @var CategoryCollection|null
  37.      */
  38.     protected $categories;
  39.     /**
  40.      * @internal (flag:FEATURE_NEXT_10078)
  41.      *
  42.      * @var ProductCollection|null
  43.      */
  44.     protected $products;
  45.     /**
  46.      * @var array|null
  47.      */
  48.     protected $config;
  49.     /**
  50.      * @var string|null
  51.      */
  52.     protected $previewMediaId;
  53.     /**
  54.      * @var MediaEntity|null
  55.      */
  56.     protected $previewMedia;
  57.     /**
  58.      * @var array|null
  59.      */
  60.     protected $customFields;
  61.     /**
  62.      * @var bool
  63.      */
  64.     protected $locked;
  65.     /**
  66.      * @internal (flag:FEATURE_NEXT_12032)
  67.      *
  68.      * @var LandingPageCollection|null
  69.      */
  70.     protected $landingPages;
  71.     public function getName(): string
  72.     {
  73.         return $this->name;
  74.     }
  75.     public function setName(string $name): void
  76.     {
  77.         $this->name $name;
  78.     }
  79.     public function getType(): string
  80.     {
  81.         return $this->type;
  82.     }
  83.     public function setType(string $type): void
  84.     {
  85.         $this->type $type;
  86.     }
  87.     public function getEntity(): ?string
  88.     {
  89.         return $this->entity;
  90.     }
  91.     public function setEntity(?string $entity): void
  92.     {
  93.         $this->entity $entity;
  94.     }
  95.     public function getSections(): ?CmsSectionCollection
  96.     {
  97.         return $this->sections;
  98.     }
  99.     public function setSections(CmsSectionCollection $sections): void
  100.     {
  101.         $this->sections $sections;
  102.     }
  103.     public function getTranslations(): ?EntityCollection
  104.     {
  105.         return $this->translations;
  106.     }
  107.     public function setTranslations(EntityCollection $translations): void
  108.     {
  109.         $this->translations $translations;
  110.     }
  111.     public function getCustomFields(): ?array
  112.     {
  113.         return $this->customFields;
  114.     }
  115.     public function setCustomFields(?array $customFields): void
  116.     {
  117.         $this->customFields $customFields;
  118.     }
  119.     public function getCategories(): ?CategoryCollection
  120.     {
  121.         return $this->categories;
  122.     }
  123.     public function setCategories(CategoryCollection $categories): void
  124.     {
  125.         $this->categories $categories;
  126.     }
  127.     /**
  128.      *@internal (flag:FEATURE_NEXT_10078)
  129.      */
  130.     public function getProducts(): ?ProductCollection
  131.     {
  132.         return $this->products;
  133.     }
  134.     /**
  135.      *@internal (flag:FEATURE_NEXT_10078)
  136.      */
  137.     public function setProducts(ProductCollection $products): void
  138.     {
  139.         $this->products $products;
  140.     }
  141.     public function getConfig(): ?array
  142.     {
  143.         return $this->config;
  144.     }
  145.     public function setConfig(array $config): void
  146.     {
  147.         $this->config $config;
  148.     }
  149.     public function getPreviewMediaId(): ?string
  150.     {
  151.         return $this->previewMediaId;
  152.     }
  153.     public function setPreviewMediaId(string $previewMediaId): void
  154.     {
  155.         $this->previewMediaId $previewMediaId;
  156.     }
  157.     public function getPreviewMedia(): ?MediaEntity
  158.     {
  159.         return $this->previewMedia;
  160.     }
  161.     public function setPreviewMedia(MediaEntity $previewMedia): void
  162.     {
  163.         $this->previewMedia $previewMedia;
  164.     }
  165.     public function getLocked(): bool
  166.     {
  167.         return $this->locked;
  168.     }
  169.     public function setLocked(bool $locked): void
  170.     {
  171.         $this->locked $locked;
  172.     }
  173.     public function getFirstElementOfType(string $type): ?CmsSlotEntity
  174.     {
  175.         $elements $this->getElementsOfType($type);
  176.         return array_shift($elements);
  177.     }
  178.     /**
  179.      * @internal (flag:FEATURE_NEXT_12032)
  180.      */
  181.     public function getLandingPages(): ?LandingPageCollection
  182.     {
  183.         return $this->landingPages;
  184.     }
  185.     /**
  186.      * @internal (flag:FEATURE_NEXT_12032)
  187.      */
  188.     public function setLandingPages(LandingPageCollection $landingPages): void
  189.     {
  190.         $this->landingPages $landingPages;
  191.     }
  192.     public function getElementsOfType(string $type): array
  193.     {
  194.         $elements = [];
  195.         if (!$this->getSections()) {
  196.             return $elements;
  197.         }
  198.         foreach ($this->getSections()->getBlocks() as $block) {
  199.             if (!$block->getSlots()) {
  200.                 continue;
  201.             }
  202.             foreach ($block->getSlots() as $slot) {
  203.                 if ($slot->getType() === $type) {
  204.                     $elements[] = $slot;
  205.                 }
  206.             }
  207.         }
  208.         return $elements;
  209.     }
  210. }