'/{_locale}/product', 'fr' => '/{_locale}/produits', ], name: 'list' )] public function list(Request $request, #[CurrentUser] ?User $user): Response { $page = $this->getPage($request); $q = u($request->query->get('q'))->toString(); $searchDto = new Search($q, $page, $user); // The DTO is modified with selected values if the form is submitted and valid $searchForm = $this->createForm(SearchFormType::class, $searchDto)->handleRequest($request); return $this->render('pages/product/list.html.twig', [ 'objects_pagination' => $this->paginate($this->meilisearch->searchObjects($searchDto)), 'services_pagination' => $this->paginate($this->meilisearch->searchServices($searchDto)), 'search_form' => $searchForm, 'services_enabled' => $this->configurationRepository->getServicesParameter(), ]); } /** * The slug is only for SEO. */ #[Route([ 'en' => '/{_locale}/product/{slug}/{id}', 'fr' => '/{_locale}/produits/{slug}/{id}', ], name: 'show', requirements: ['slug' => Requirement::ASCII_SLUG, 'id' => Requirement::UUID_V6] )] public function show(string $slug, string $id): Response { /** @var ?Product $product */ $product = $this->productRepository->find(['id' => $id]); if ($product === null) { throw new NotFoundHttpException(); } if (($product->getType() === ProductType::SERVICE && $this->configurationRepository->getServicesParameter()) || $product->getType() === ProductType::OBJECT) { try { /** @var Product $product */ $product = $this->queryBus->query(new GetProductByIdQuery(Uuid::fromString($id))); } catch (HandlerFailedException $e) { throw $this->createNotFoundException($e->getMessage()); } return $this->render('pages/product/show.html.twig', compact('slug', 'id', 'product')); } throw new GoneHttpException(); } }