fix gitlab tests

This commit is contained in:
2017-06-22 23:05:19 +02:00
parent 5a3f360822
commit 332bec6e83
4 changed files with 41 additions and 12 deletions

View File

@@ -52,12 +52,32 @@ class ReportController extends Controller
$reachableScopes = $this->get('chill.main.security.authorization.helper')
->getReachableScopes($this->getUser(), new Role('CHILL_REPORT_SEE'),
$person->getCenter());
$reports = $em->getRepository('ChillReportBundle:Report')
->findBy(array('person' => $person, 'scope' => $reachableScopes));
$total = $em
->createQuery("SELECT COUNT(r.id) FROM ChillReportBundle:Report r "
. "WHERE r.person = :person AND r.scope IN (:scopes) ")
->setParameter('person', $person)
->setParameter('scopes', $reachableScopes)
->getSingleScalarResult();
// get the PaginatorFactory
$paginator = $this->get('chill_main.paginator_factory')->create($total);
$reports = $em->createQuery('SELECT r
FROM ChillReportBundle:Report r
WHERE r.person = :person AND r.scope IN (:scopes)
ORDER BY r.date DESC')
->setParameter('person', $person)
->setParameter('scopes', $reachableScopes)
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
->setMaxResults($paginator->getItemsPerPage())
->getResult()
;
return $this->render('ChillReportBundle:Report:list.html.twig', array(
'reports' => $reports,
'person' => $person
'reports' => $reports,
'person' => $person,
'paginator' => $paginator
));
}