mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
adjust countperson to make it work again
This commit is contained in:
parent
ea12c60154
commit
c72dc83c06
@ -15,8 +15,8 @@ use Chill\MainBundle\Export\ExportInterface;
|
||||
use Chill\MainBundle\Export\FormatterInterface;
|
||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
@ -25,19 +25,18 @@ use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
class CountPerson implements ExportInterface, GroupedExportInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
protected PersonRepository $personRepository;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em
|
||||
PersonRepository $personRepository
|
||||
) {
|
||||
$this->entityManager = $em;
|
||||
$this->personRepository = $personRepository;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// No form necessary
|
||||
}
|
||||
|
||||
public function getAllowedFormattersTypes()
|
||||
@ -47,7 +46,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return 'Count peoples by various parameters.';
|
||||
return 'Count people by various parameters.';
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
@ -76,7 +75,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Count peoples';
|
||||
return 'Count people';
|
||||
}
|
||||
|
||||
public function getType()
|
||||
@ -95,10 +94,9 @@ class CountPerson implements ExportInterface, GroupedExportInterface
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
$qb = $this->personRepository->createQueryBuilder('person');
|
||||
|
||||
$qb->select('COUNT(person.id) AS export_result')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
->join('person.center', 'center')
|
||||
->andWhere('center IN (:authorized_centers)')
|
||||
->setParameter('authorized_centers', $centers);
|
||||
@ -113,7 +111,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
|
||||
|
||||
public function supportsModifiers()
|
||||
{
|
||||
return [Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN];
|
||||
return [Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN, Declarations::ACP_SHARED];
|
||||
}
|
||||
|
||||
public function getGroup(): string
|
||||
|
@ -31,6 +31,11 @@ final class PersonRepository implements ObjectRepository
|
||||
$this->repository = $entityManager->getRepository(Person::class);
|
||||
}
|
||||
|
||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||
{
|
||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $centers
|
||||
*
|
||||
|
@ -2,18 +2,15 @@ services:
|
||||
|
||||
chill.person.export.count_person:
|
||||
class: Chill\PersonBundle\Export\Export\CountPerson
|
||||
arguments:
|
||||
- "@doctrine.orm.entity_manager"
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export, alias: count_person }
|
||||
|
||||
chill.person.export.list_person:
|
||||
class: Chill\PersonBundle\Export\Export\ListPerson
|
||||
arguments:
|
||||
- "@doctrine.orm.entity_manager"
|
||||
- "@translator"
|
||||
- "@chill.main.helper.translatable_string"
|
||||
- "@chill.custom_field.provider"
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export, alias: list_person }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user