adjust countperson to make it work again

This commit is contained in:
2022-08-02 13:44:28 +02:00
parent ea12c60154
commit c72dc83c06
3 changed files with 19 additions and 19 deletions

View File

@@ -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