custom/plugins/SwagCmsExtensions/src/Service/Content/Cms/SalesChannel/SalesChannelCmsPageLoaderQuickviewDecorator.php line 32

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\Quickview\CmsBlockEntityExtension;
  14. use Symfony\Component\HttpFoundation\Request;
  15. class SalesChannelCmsPageLoaderQuickviewDecorator implements SalesChannelCmsPageLoaderInterface
  16. {
  17.     public const QUICKVIEW_ASSOCIATION_PATH 'sections.blocks.' CmsBlockEntityExtension::QUICKVIEW_ASSOCIATION_PROPERTY_NAME;
  18.     private SalesChannelCmsPageLoaderInterface $inner;
  19.     public function __construct(SalesChannelCmsPageLoaderInterface $inner)
  20.     {
  21.         $this->inner $inner;
  22.     }
  23.     /**
  24.      * @param array<string, mixed>|null $config
  25.      */
  26.     public function load(
  27.         Request $request,
  28.         Criteria $criteria,
  29.         SalesChannelContext $context,
  30.         ?array $config null,
  31.         ?ResolverContext $resolverContext null
  32.     ): EntitySearchResult {
  33.         return $this->inner->load(
  34.             $request,
  35.             $this->addQuickviewAssociation($criteria),
  36.             $context,
  37.             $config,
  38.             $resolverContext
  39.         );
  40.     }
  41.     protected function addQuickviewAssociation(Criteria $criteria): Criteria
  42.     {
  43.         return $criteria->addAssociation(self::QUICKVIEW_ASSOCIATION_PATH);
  44.     }
  45. }