mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
implementing the pagination api and the search preview
This commit is contained in:
@@ -10,6 +10,8 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Symfony\Component\Templating\EngineInterface as TemplatingEngine;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Search\SearchInterface;
|
||||
|
||||
/**
|
||||
* Search within Events.
|
||||
@@ -55,18 +57,27 @@ class EventSearch extends AbstractSearch
|
||||
*/
|
||||
private $templating;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var PaginatorFactory
|
||||
*/
|
||||
private $paginationFactory;
|
||||
|
||||
const NAME = 'event_regular';
|
||||
|
||||
public function __construct(
|
||||
TokenStorageInterface $tokenStorage,
|
||||
EntityRepository $eventRepository,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
TemplatingEngine $templating
|
||||
TemplatingEngine $templating,
|
||||
PaginatorFactory $paginatorFactory
|
||||
)
|
||||
{
|
||||
$this->user = $tokenStorage->getToken()->getUser();
|
||||
$this->er = $eventRepository;
|
||||
$this->helper = $authorizationHelper;
|
||||
$this->templating = $templating;
|
||||
$this->paginationFactory = $paginatorFactory;
|
||||
}
|
||||
|
||||
public function supports($domain)
|
||||
@@ -84,13 +95,21 @@ class EventSearch extends AbstractSearch
|
||||
return 3000;
|
||||
}
|
||||
|
||||
public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array())
|
||||
public function renderResult(array $terms, $start = 0, $limit = 50,
|
||||
array $options = array())
|
||||
{
|
||||
$total = $this->count($terms);
|
||||
$paginator = $this->paginationFactory->create($total);
|
||||
|
||||
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']),
|
||||
'total' => $this->count($terms)
|
||||
'total' => $total,
|
||||
'start' => $start,
|
||||
'preview' => $options[SearchInterface::SEARCH_PREVIEW],
|
||||
'paginator' => $paginator,
|
||||
'search_name' => self::NAME
|
||||
));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user