mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
parent
6fcf5944a0
commit
79e96fbb5c
@ -27,6 +27,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\MainBundle\Export\FormatterInterface;
|
use Chill\MainBundle\Export\FormatterInterface;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -35,6 +36,19 @@ use Chill\MainBundle\Export\FormatterInterface;
|
|||||||
*/
|
*/
|
||||||
class CountPerson implements ExportInterface
|
class CountPerson implements ExportInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var EntityManagerInterface
|
||||||
|
*/
|
||||||
|
protected $entityManager;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
EntityManagerInterface $em
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->entityManager = $em;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -64,10 +78,12 @@ class CountPerson implements ExportInterface
|
|||||||
* @param QueryBuilder $qb
|
* @param QueryBuilder $qb
|
||||||
* @return QueryBuilder
|
* @return QueryBuilder
|
||||||
*/
|
*/
|
||||||
public function initiateQuery(QueryBuilder $qb, array $requiredModifiers, array $acl, array $data = array())
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
|
||||||
{
|
{
|
||||||
$centers = array_map(function($el) { return $el['center']; }, $acl);
|
$centers = array_map(function($el) { return $el['center']; }, $acl);
|
||||||
|
|
||||||
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
|
||||||
$qb->select('COUNT(person.id) AS export_result')
|
$qb->select('COUNT(person.id) AS export_result')
|
||||||
->from('ChillPersonBundle:Person', 'person')
|
->from('ChillPersonBundle:Person', 'person')
|
||||||
->join('person.center', 'center')
|
->join('person.center', 'center')
|
||||||
@ -79,7 +95,7 @@ class CountPerson implements ExportInterface
|
|||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResult(QueryBuilder $qb, $data)
|
public function getResult($qb, $data)
|
||||||
{
|
{
|
||||||
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,8 @@ services:
|
|||||||
|
|
||||||
chill.person.export.export_count_person:
|
chill.person.export.export_count_person:
|
||||||
class: Chill\PersonBundle\Export\Export\CountPerson
|
class: Chill\PersonBundle\Export\Export\CountPerson
|
||||||
|
arguments:
|
||||||
|
- "@doctrine.orm.entity_manager"
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export, alias: count_person }
|
- { name: chill.export, alias: count_person }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user