mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-04 05:44:58 +00:00
subscribe a person since listByPerson context (issue #19)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user