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

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