replace search api by a first workin implementation

This commit is contained in:
2021-06-28 22:01:33 +02:00
parent a35f3363b2
commit e845d9ba90
8 changed files with 326 additions and 50 deletions

View File

@@ -36,6 +36,7 @@ use Chill\MainBundle\Search\SearchProvider;
use Symfony\Contracts\Translation\TranslatorInterface;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Search\SearchApi;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
/**
* Class SearchController
@@ -151,11 +152,14 @@ class SearchController extends AbstractController
{
//TODO this is an incomplete implementation
$query = $request->query->get('q', '');
$types = $request->query->get('type', []);
$results = $this->searchApi->getResults($query, 0, 150);
$paginator = $this->paginatorFactory->create(count($results));
if (count($types) === 0) {
throw new BadRequestException("The request must contains at "
." one type");
}
$collection = new Collection($results, $paginator);
$collection = $this->searchApi->getResults($query, $types, []);
return $this->json($collection);
}