mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
exports: add a new intensity aggregator
This commit is contained in:
parent
5940e2c0b7
commit
f817ca9671
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class IntensityAggregator implements AggregatorInterface
|
||||
{
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
if ($value === '_header') {
|
||||
return 'Intensity';
|
||||
}
|
||||
switch ($value) {
|
||||
case 'occasional':
|
||||
return $this->translator->trans('is occasional');
|
||||
case 'regular':
|
||||
return $this->translator->trans('is regular');
|
||||
default:
|
||||
throw new LogicException(sprintf('The value %s is not valid', $value));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['intensity_aggregator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by intensity';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->addSelect('acp.intensity AS intensity_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('intensity_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('intensity_aggregator');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@ -226,3 +226,10 @@ services:
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_emergency_aggregator }
|
||||
|
||||
chill.person.export.aggregator_intensity:
|
||||
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\IntensityAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_intensity_aggregator }
|
||||
|
@ -490,6 +490,8 @@ Accepted intensities: ''
|
||||
is occasional: le parcours est ponctuel
|
||||
is regular: le parcours est régulier
|
||||
"Filtered by intensity: only %intensity%": "Filtré par intensité: uniquement si %intensity%"
|
||||
Intensity: Intensité
|
||||
Group by intensity: Grouper par intensité
|
||||
|
||||
Filtered by active on date: Filtrer les parcours actifs à une date
|
||||
On date: Actifs à cette date
|
||||
|
Loading…
x
Reference in New Issue
Block a user