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

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