mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Merge branch 'master' of git.framasoft.org:Chill-project/Chill-Person
This commit is contained in:
commit
c5bec75d82
@ -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);
|
||||
}
|
||||
|
@ -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 }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user