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

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\Log\Package;
  9. use Shopware\Core\Framework\Routing\Annotation\Entity;
  10. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  11. use Shopware\Core\Framework\Routing\Annotation\Since;
  12. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  16. /**
  17.  * @Route(defaults={"_routeScope"={"store-api"}})
  18.  */
  19. #[Package('system-settings')]
  20. class ResolvedCriteriaProductSearchRoute extends AbstractProductSearchRoute
  21. {
  22.     private AbstractProductSearchRoute $decorated;
  23.     private EventDispatcherInterface $eventDispatcher;
  24.     private DefinitionInstanceRegistry $registry;
  25.     private RequestCriteriaBuilder $criteriaBuilder;
  26.     /**
  27.      * @internal
  28.      */
  29.     public function __construct(AbstractProductSearchRoute $decoratedEventDispatcherInterface $eventDispatcherDefinitionInstanceRegistry $registryRequestCriteriaBuilder $criteriaBuilder)
  30.     {
  31.         $this->decorated $decorated;
  32.         $this->eventDispatcher $eventDispatcher;
  33.         $this->registry $registry;
  34.         $this->criteriaBuilder $criteriaBuilder;
  35.     }
  36.     public function getDecorated(): AbstractProductSearchRoute
  37.     {
  38.         return $this->decorated;
  39.     }
  40.     /**
  41.      * @Since("6.2.0.0")
  42.      * @Entity("product")
  43.      * @Route("/store-api/search", name="store-api.search", methods={"POST"})
  44.      */
  45.     public function load(Request $requestSalesChannelContext $contextCriteria $criteria): ProductSearchRouteResponse
  46.     {
  47.         $criteria $this->criteriaBuilder->handleRequest(
  48.             $request,
  49.             $criteria,
  50.             $this->registry->getByEntityName('product'),
  51.             $context->getContext()
  52.         );
  53.         $this->eventDispatcher->dispatch(
  54.             new ProductSearchCriteriaEvent($request$criteria$context),
  55.             ProductEvents::PRODUCT_SEARCH_CRITERIA
  56.         );
  57.         return $this->getDecorated()->load($request$context$criteria);
  58.     }
  59. }