add pagination to timeline

This commit is contained in:
Julien Fastré 2017-08-19 23:08:41 +02:00
parent f6e91e6f77
commit 0031597e88
2 changed files with 22 additions and 3 deletions

View File

@ -43,11 +43,27 @@ class TimelinePersonController extends Controller
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
/* @var $timelineBuilder \Chill\MainBundle\Timeline\TimelineBuilder */
$timelineBuilder = $this->get('chill.main.timeline_builder');
$paginatorFactory = $this->get('chill_main.paginator_factory');
$nbItems = $timelineBuilder->countItems('person',
[ 'person' => $person ]
);
$paginator = $paginatorFactory->create($nbItems);
return $this->render('ChillPersonBundle:Timeline:index.html.twig', array
(
'timeline' => $this->get('chill.main.timeline_builder')
->getTimelineHTML('person', array('person' => $person)),
'person' => $person
'timeline' => $timelineBuilder->getTimelineHTML(
'person',
array('person' => $person),
$paginator->getCurrentPage()->getFirstItemNumber(),
$paginator->getItemsPerPage()
),
'person' => $person,
'nb_items' => $nbItems,
'paginator' => $paginator
)
);
}

View File

@ -29,4 +29,7 @@ This view should receive those arguments:
{% block personcontent %}
{{ timeline|raw }}
{% if nb_items > paginator.getItemsPerPage %}
{{ chill_pagination(paginator) }}
{% endif %}
{% endblock personcontent %}