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

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.     private SalesChannelCmsPageLoaderInterface $inner;
  21.     public function __construct(SalesChannelCmsPageLoaderInterface $inner)
  22.     {
  23.         $this->inner $inner;
  24.     }
  25.     /**
  26.      * @param array<string, mixed>|null $config
  27.      */
  28.     public function load(
  29.         Request $request,
  30.         Criteria $criteria,
  31.         SalesChannelContext $context,
  32.         ?array $config null,
  33.         ?ResolverContext $resolverContext null
  34.     ): EntitySearchResult {
  35.         return $this->inner->load(
  36.             $request,
  37.             $this->addScrollNavigationAssociations($criteria),
  38.             $context,
  39.             $config,
  40.             $resolverContext
  41.         );
  42.     }
  43.     protected function addScrollNavigationAssociations(Criteria $criteria): Criteria
  44.     {
  45.         return $criteria
  46.             ->addAssociation(self::SCROLL_NAVIGATION_PAGE_SETTINGS_PATH)
  47.             ->addAssociation(self::SCROLL_NAVIGATION_ASSOCIATION_PATH);
  48.     }
  49. }