mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
list events by person, add pagination
This commit is contained in:
@@ -259,11 +259,36 @@ class EventController extends Controller
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||
|
||||
$participations = $em->getRepository('ChillEventBundle:Participation')
|
||||
->findBy(
|
||||
array('person' => $person)
|
||||
);
|
||||
|
||||
$total = $em
|
||||
->createQuery("
|
||||
SELECT COUNT (participation.id)
|
||||
FROM ChillEventBundle:Participation participation
|
||||
WHERE participation.person = :person_id
|
||||
")
|
||||
->setParameter(':person_id', $person_id)
|
||||
->getSingleScalarResult();
|
||||
|
||||
/* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory */
|
||||
$paginatorFactory = $this->get('chill_main.paginator_factory');
|
||||
$paginator = $paginatorFactory->create($total);
|
||||
|
||||
$participations = $em
|
||||
->createQuery("
|
||||
SELECT participation
|
||||
FROM ChillEventBundle:Participation participation
|
||||
WHERE participation.person = :person_id
|
||||
")
|
||||
->setParameters(array(
|
||||
':person_id' => $person_id,
|
||||
))
|
||||
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
|
||||
->setMaxResults($paginator->getItemsPerPage())
|
||||
->getResult()
|
||||
;
|
||||
|
||||
|
||||
$privacyEvent = new PrivacyEvent($person, array(
|
||||
'element_class' => Participation::class,
|
||||
'action' => 'list'
|
||||
@@ -272,7 +297,8 @@ class EventController extends Controller
|
||||
|
||||
return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array(
|
||||
'participations' => $participations,
|
||||
'person' => $person
|
||||
'person' => $person,
|
||||
'paginator' => $paginator
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user