vendor/shopware/core/Content/Cms/Aggregate/CmsSection/CmsSectionCollection.php line 17

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Cms\Aggregate\CmsSection;
  3. use Shopware\Core\Content\Cms\Aggregate\CmsBlock\CmsBlockCollection;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
  5. /**
  6.  * @method void                  add(CmsSectionEntity $entity)
  7.  * @method void                  set(string $key, CmsSectionEntity $entity)
  8.  * @method CmsSectionEntity[]    getIterator()
  9.  * @method CmsSectionEntity[]    getElements()
  10.  * @method CmsSectionEntity|null get(string $key)
  11.  * @method CmsSectionEntity|null first()
  12.  * @method CmsSectionEntity|null last()
  13.  */
  14. class CmsSectionCollection extends EntityCollection
  15. {
  16.     public function getBlocks(): CmsBlockCollection
  17.     {
  18.         $blocks = new CmsBlockCollection();
  19.         /** @var CmsSectionEntity $section */
  20.         foreach ($this->elements as $section) {
  21.             if (!$section->getBlocks()) {
  22.                 continue;
  23.             }
  24.             $blocks->merge($section->getBlocks());
  25.         }
  26.         return $blocks;
  27.     }
  28.     public function getApiAlias(): string
  29.     {
  30.         return 'cms_page_section_collection';
  31.     }
  32.     protected function getExpectedClass(): string
  33.     {
  34.         return CmsSectionEntity::class;
  35.     }
  36. }