mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
vendee filters and aggregators moved to root folder
This commit is contained in:
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
|
||||
|
||||
use App\Repository\VendeePerson\SituationProfessionelleRepository;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
// todo FIX ERROR AND MOVE TO VENDEE ROOT FOLDER
|
||||
|
||||
final class ProfessionalSituationAggregator implements AggregatorInterface
|
||||
{
|
||||
private SituationProfessionelleRepository $professionalSituationRepository;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(SituationProfessionelleRepository $professionalSituationRepository, TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
$this->professionalSituationRepository = $professionalSituationRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->resetDQLPart('from');
|
||||
$qb->from('App:VendeePerson', 'vp');
|
||||
$qb->join('vp.person', 'person');
|
||||
$qb->join('person.center', 'center');
|
||||
|
||||
$qb->join('vp.situationProfessionelle', 'sp');
|
||||
$qb->addSelect('sp.id as professional_situation_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('professional_situation_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('professional_situation_aggregator');
|
||||
}
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'Professional situation';
|
||||
}
|
||||
|
||||
$g = $this->professionalSituationRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize($g->getName());;
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return ['professional_situation_aggregator'];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Group people by their professional situation';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user