From e145892e878323cdb76c009816ebf0173645c1aa Mon Sep 17 00:00:00 2001 From: brabli <67018167+brabli@users.noreply.github.com> Date: Fri, 8 May 2026 11:18:50 +0100 Subject: [PATCH] Simplify example --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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()]), ]; }