| @@ 13-44 (lines=32) @@ | ||
| 10 | use Symfony\Component\HttpFoundation\Response; |
|
| 11 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 12 | ||
| 13 | final class ShowProductCatalogBySlugAction |
|
| 14 | { |
|
| 15 | /** @var ViewHandlerInterface */ |
|
| 16 | private $viewHandler; |
|
| 17 | ||
| 18 | /** @var ProductCatalogViewRepositoryInterface */ |
|
| 19 | private $productCatalogQuery; |
|
| 20 | ||
| 21 | public function __construct( |
|
| 22 | ViewHandlerInterface $viewHandler, |
|
| 23 | ProductCatalogViewRepositoryInterface $productCatalogQuery |
|
| 24 | ) { |
|
| 25 | $this->viewHandler = $viewHandler; |
|
| 26 | $this->productCatalogQuery = $productCatalogQuery; |
|
| 27 | } |
|
| 28 | ||
| 29 | public function __invoke(Request $request): Response |
|
| 30 | { |
|
| 31 | if (!$request->query->has('channel')) { |
|
| 32 | throw new NotFoundHttpException('Cannot find product without channel provided'); |
|
| 33 | } |
|
| 34 | ||
| 35 | $page = $this->productCatalogQuery->findByTaxonSlug( |
|
| 36 | $request->attributes->get('taxonomySlug'), |
|
| 37 | $request->query->get('locale'), |
|
| 38 | $request->query->get('channel'), |
|
| 39 | new PaginatorDetails($request->attributes->get('_route'), $request->query->all()) |
|
| 40 | ); |
|
| 41 | ||
| 42 | return $this->viewHandler->handle(View::create($page, Response::HTTP_OK)); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 13-43 (lines=31) @@ | ||
| 10 | use Symfony\Component\HttpFoundation\Response; |
|
| 11 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 12 | ||
| 13 | final class ShowProductReviewsByCodeAction |
|
| 14 | { |
|
| 15 | /** @var ViewHandlerInterface */ |
|
| 16 | private $viewHandler; |
|
| 17 | ||
| 18 | /** @var ProductReviewsViewRepositoryInterface */ |
|
| 19 | private $productReviewsViewRepository; |
|
| 20 | ||
| 21 | public function __construct( |
|
| 22 | ViewHandlerInterface $viewHandler, |
|
| 23 | ProductReviewsViewRepositoryInterface $productReviewsViewRepository |
|
| 24 | ) { |
|
| 25 | $this->viewHandler = $viewHandler; |
|
| 26 | $this->productReviewsViewRepository = $productReviewsViewRepository; |
|
| 27 | } |
|
| 28 | ||
| 29 | public function __invoke(Request $request): Response |
|
| 30 | { |
|
| 31 | if (!$request->query->has('channel')) { |
|
| 32 | throw new NotFoundHttpException('Cannot find product without channel provided'); |
|
| 33 | } |
|
| 34 | ||
| 35 | $page = $this->productReviewsViewRepository->getByProductCode( |
|
| 36 | $request->attributes->get('code'), |
|
| 37 | $request->query->get('channel'), |
|
| 38 | new PaginatorDetails($request->attributes->get('_route'), $request->query->all()) |
|
| 39 | ); |
|
| 40 | ||
| 41 | return $this->viewHandler->handle(View::create($page, Response::HTTP_OK)); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 13-44 (lines=32) @@ | ||
| 10 | use Symfony\Component\HttpFoundation\Response; |
|
| 11 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 12 | ||
| 13 | final class ShowProductReviewsBySlugAction |
|
| 14 | { |
|
| 15 | /** @var ViewHandlerInterface */ |
|
| 16 | private $viewHandler; |
|
| 17 | ||
| 18 | /** @var ProductReviewsViewRepositoryInterface */ |
|
| 19 | private $productReviewsViewRepository; |
|
| 20 | ||
| 21 | public function __construct( |
|
| 22 | ViewHandlerInterface $viewHandler, |
|
| 23 | ProductReviewsViewRepositoryInterface $productReviewsViewRepository |
|
| 24 | ) { |
|
| 25 | $this->viewHandler = $viewHandler; |
|
| 26 | $this->productReviewsViewRepository = $productReviewsViewRepository; |
|
| 27 | } |
|
| 28 | ||
| 29 | public function __invoke(Request $request): Response |
|
| 30 | { |
|
| 31 | if (!$request->query->has('channel')) { |
|
| 32 | throw new NotFoundHttpException('Cannot find product without channel provided'); |
|
| 33 | } |
|
| 34 | ||
| 35 | $page = $this->productReviewsViewRepository->getByProductSlug( |
|
| 36 | $request->attributes->get('slug'), |
|
| 37 | $request->query->get('locale'), |
|
| 38 | $request->query->get('channel'), |
|
| 39 | new PaginatorDetails($request->attributes->get('_route'), $request->query->all()) |
|
| 40 | ); |
|
| 41 | ||
| 42 | return $this->viewHandler->handle(View::create($page, Response::HTTP_OK)); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||