diff --git a/README.md b/README.md index 3297b44..6d2abee 100644 --- a/README.md +++ b/README.md @@ -61,21 +61,18 @@ class Company implements SearchableInterface Query the index from a controller and resolve each hit to a URL: ```php -#[Route('/search', name: 'app_search', methods: ['GET'])] +#[Route('/search', name: 'app_search')] public function search(Request $request, SearchIndexRepository $repo): Response { $routes = [Company::class => 'app_company_show']; + $rows = $repo->findAllPagination($request->query->get('q', ''))->getResult(); $results = []; foreach ($rows as [$index]) { - $route = $routes[$index->getEntityClass()] ?? null; - if ($route === null) { - continue; - } $results[] = [ 'title' => $index->getTitle(), - 'url' => $this->generateUrl($route, ['id' => $index->getEntityId()]), + 'url' => $this->generateUrl($routes[$index->getEntityClass()], ['id' => $index->getEntityId()]), ]; }