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

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