adapt to new exportInterface

see Chill-project/Chill-Main#9
This commit is contained in:
Julien Fastré 2016-04-25 21:59:13 +02:00
parent 6fcf5944a0
commit 79e96fbb5c
2 changed files with 20 additions and 2 deletions

View File

@ -27,6 +27,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Security\Core\Role\Role;
use Chill\PersonBundle\Export\Declarations;
use Chill\MainBundle\Export\FormatterInterface;
use Doctrine\ORM\EntityManagerInterface;
/**
*
@ -35,6 +36,19 @@ use Chill\MainBundle\Export\FormatterInterface;
*/
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
* @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);
$qb = $this->entityManager->createQueryBuilder();
$qb->select('COUNT(person.id) AS export_result')
->from('ChillPersonBundle:Person', 'person')
->join('person.center', 'center')
@ -79,7 +95,7 @@ class CountPerson implements ExportInterface
return $qb;
}
public function getResult(QueryBuilder $qb, $data)
public function getResult($qb, $data)
{
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
}

View File

@ -72,6 +72,8 @@ services:
chill.person.export.export_count_person:
class: Chill\PersonBundle\Export\Export\CountPerson
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: chill.export, alias: count_person }