list events by person, add pagination

This commit is contained in:
2019-01-17 13:59:20 +01:00
parent 7abf403463
commit d07cbb15da
2 changed files with 40 additions and 11 deletions

View File

@@ -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
));
}
}