vendor/shopware/core/Content/Product/SalesChannel/Search/ResolvedCriteriaProductSearchRoute.php line 52

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Product\SalesChannel\Search;
  3. use Shopware\Core\Content\Product\Events\ProductSearchCriteriaEvent;
  4. use Shopware\Core\Content\Product\ProductEvents;
  5. use Shopware\Core\Framework\DataAbstractionLayer\DefinitionInstanceRegistry;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Search\RequestCriteriaBuilder;
  8. use Shopware\Core\Framework\Routing\Annotation\Entity;
  9. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  10. use Shopware\Core\Framework\Routing\Annotation\Since;
  11. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  15. /**
  16.  * @Route(defaults={"_routeScope"={"store-api"}})
  17.  */
  18. class ResolvedCriteriaProductSearchRoute extends AbstractProductSearchRoute
  19. {
  20.     private AbstractProductSearchRoute $decorated;
  21.     private EventDispatcherInterface $eventDispatcher;
  22.     private DefinitionInstanceRegistry $registry;
  23.     private RequestCriteriaBuilder $criteriaBuilder;
  24.     /**
  25.      * @internal
  26.      */
  27.     public function __construct(AbstractProductSearchRoute $decoratedEventDispatcherInterface $eventDispatcherDefinitionInstanceRegistry $registryRequestCriteriaBuilder $criteriaBuilder)
  28.     {
  29.         $this->decorated $decorated;
  30.         $this->eventDispatcher $eventDispatcher;
  31.         $this->registry $registry;
  32.         $this->criteriaBuilder $criteriaBuilder;
  33.     }
  34.     public function getDecorated(): AbstractProductSearchRoute
  35.     {
  36.         return $this->decorated;
  37.     }
  38.     /**
  39.      * @Since("6.2.0.0")
  40.      * @Entity("product")
  41.      * @Route("/store-api/search", name="store-api.search", methods={"POST"})
  42.      */
  43.     public function load(Request $requestSalesChannelContext $contextCriteria $criteria): ProductSearchRouteResponse
  44.     {
  45.         $criteria $this->criteriaBuilder->handleRequest(
  46.             $request,
  47.             $criteria,
  48.             $this->registry->getByEntityName('product'),
  49.             $context->getContext()
  50.         );
  51.         $this->eventDispatcher->dispatch(
  52.             new ProductSearchCriteriaEvent($request$criteria$context),
  53.             ProductEvents::PRODUCT_SEARCH_CRITERIA
  54.         );
  55.         return $this->getDecorated()->load($request$context$criteria);
  56.     }
  57. }