custom/plugins/SwagCmsExtensions/src/Service/Content/Cms/SalesChannel/SalesChannelCmsPageLoaderScrollNavigationDecorator.php line 44

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /*
  3.  * (c) shopware AG <info@shopware.com>
  4.  * For the full copyright and license information, please view the LICENSE
  5.  * file that was distributed with this source code.
  6.  */
  7. namespace Swag\CmsExtensions\Service\Content\Cms\SalesChannel;
  8. use Shopware\Core\Content\Cms\DataResolver\ResolverContext\ResolverContext;
  9. use Shopware\Core\Content\Cms\SalesChannel\SalesChannelCmsPageLoaderInterface;
  10. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  11. use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult;
  12. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  13. use Swag\CmsExtensions\Extension\Feature\ScrollNavigation\CmsPageEntityExtension;
  14. use Swag\CmsExtensions\Extension\Feature\ScrollNavigation\CmsSectionEntityExtension;
  15. use Symfony\Component\HttpFoundation\Request;
  16. class SalesChannelCmsPageLoaderScrollNavigationDecorator implements SalesChannelCmsPageLoaderInterface
  17. {
  18.     public const SCROLL_NAVIGATION_PAGE_SETTINGS_PATH CmsPageEntityExtension::SCROLL_NAVIGATION_PAGE_SETTINGS_PROPERTY_NAME;
  19.     public const SCROLL_NAVIGATION_ASSOCIATION_PATH 'sections.' CmsSectionEntityExtension::SCROLL_NAVIGATION_ASSOCIATION_PROPERTY_NAME;
  20.     /**
  21.      * @var SalesChannelCmsPageLoaderInterface
  22.      */
  23.     private $inner;
  24.     public function __construct(SalesChannelCmsPageLoaderInterface $inner)
  25.     {
  26.         $this->inner $inner;
  27.     }
  28.     /**
  29.      * @param array<string, mixed>|null $config
  30.      */
  31.     public function load(
  32.         Request $request,
  33.         Criteria $criteria,
  34.         SalesChannelContext $context,
  35.         ?array $config null,
  36.         ?ResolverContext $resolverContext null
  37.     ): EntitySearchResult {
  38.         return $this->inner->load(
  39.             $request,
  40.             $this->addScrollNavigationAssociations($criteria),
  41.             $context,
  42.             $config,
  43.             $resolverContext
  44.         );
  45.     }
  46.     protected function addScrollNavigationAssociations(Criteria $criteria): Criteria
  47.     {
  48.         return $criteria
  49.             ->addAssociation(self::SCROLL_NAVIGATION_PAGE_SETTINGS_PATH)
  50.             ->addAssociation(self::SCROLL_NAVIGATION_ASSOCIATION_PATH);
  51.     }
  52. }