do not display similar search results if null

This commit is contained in:
Mat 2018-11-06 15:19:02 +01:00
parent 7be2d408f9
commit 99ca79d86e

View File

@ -113,21 +113,30 @@ class SimilarityPersonSearch extends AbstractSearch
$total = $this->count($terms); $total = $this->count($terms);
$paginator = $this->paginatorFactory->create($total); $paginator = $this->paginatorFactory->create($total);
if ($format === 'html') { if ($format === 'html')
return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig', {
array( if ($total !== 0)
'persons' => $this->search($terms, $start, $limit, $options), {
'pattern' => $this->recomposePattern($terms, array('nationality', return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig',
'firstname', 'lastname', 'birthdate', 'gender', array(
'birthdate-before','birthdate-after'), $terms['_domain']), 'persons' => $this->search($terms, $start, $limit, $options),
'total' => $total, 'pattern' => $this->recomposePattern($terms, array('nationality',
'start' => $start, 'firstname', 'lastname', 'birthdate', 'gender',
'search_name' => self::NAME, 'birthdate-before','birthdate-after'), $terms['_domain']),
'preview' => $options[SearchInterface::SEARCH_PREVIEW_OPTION], 'total' => $total,
'paginator' => $paginator, 'start' => $start,
'title' => "Similar persons" 'search_name' => self::NAME,
)); 'preview' => $options[SearchInterface::SEARCH_PREVIEW_OPTION],
} elseif ($format === 'json') { 'paginator' => $paginator,
'title' => "Similar persons"
));
}
else {
return null;
}
} elseif ($format === 'json')
{
return [ return [
'results' => $this->search($terms, $start, $limit, \array_merge($options, [ 'simplify' => true ])), 'results' => $this->search($terms, $start, $limit, \array_merge($options, [ 'simplify' => true ])),
'pagination' => [ 'pagination' => [