mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Merge branch 'features/api-search' into 'master'
Features/api search See merge request Chill-Projet/chill-bundles!98
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user