subscribe a person since listByPerson context (issue #19)

This commit is contained in:
2019-05-02 11:35:15 +02:00
parent aa9141be1d
commit ee8f303d25
11 changed files with 478 additions and 11 deletions

View File

@@ -3,6 +3,7 @@
namespace Chill\EventBundle\Search;
use Chill\EventBundle\Entity\Event;
use Chill\MainBundle\Search\AbstractSearch;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@@ -101,7 +102,8 @@ class EventSearch extends AbstractSearch
$total = $this->count($terms);
$paginator = $this->paginationFactory->create($total);
return $this->templating->render('ChillEventBundle:Event:list.html.twig',
if ($format === 'html') {
return $this->templating->render('ChillEventBundle:Event:list.html.twig',
array(
'events' => $this->search($terms, $start, $limit, $options),
'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']),
@@ -111,6 +113,23 @@ class EventSearch extends AbstractSearch
'paginator' => $paginator,
'search_name' => self::NAME
));
}
else if ($format === 'json') {
$results = [];
$search = $this->search($terms, $start, $limit, $options);
foreach ($search as $item) {
$results[] = [
'id' => $item->getId(),
'text' => $item->getDate()->format('d-m-Y, H:i'). ' → ' .$item->getName()
];
}
return [
'results' => $results,
'pagination' => [
'more' => $paginator->hasNextPage()
]
];
}
}
protected function getAvailableTerms()
@@ -207,8 +226,6 @@ class EventSearch extends AbstractSearch
$qb->andWhere($where);
}
return $qb;
}
}