mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
exports: create origin filter
This commit is contained in:
parent
04ca61be81
commit
e56520f4b1
95
src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php
Normal file
95
src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use phpDocumentor\Reflection\Types\Boolean;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class OriginFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var TranslatableStringHelper
|
||||||
|
*/
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
TranslatableStringHelper $translatableStringHelper
|
||||||
|
) {
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_origins', EntityType::class, [
|
||||||
|
'class' => Origin::class,
|
||||||
|
'choice_label' => function (Origin $o) {
|
||||||
|
return $this->translatableStringHelper->localize($o->getLabel());
|
||||||
|
},
|
||||||
|
'multiple' => false,
|
||||||
|
'expanded' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter by origin';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
return ['Filtered by origins: only %origin%', [
|
||||||
|
'%origin%' => $this->translatableStringHelper->localize(
|
||||||
|
$data['accepted_origins']->getLabel())
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
$clause = $qb->expr()->eq('acp.origin', ':origin');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('origin', $data['accepted_origins']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -86,6 +86,13 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: accompanyingcourse_step_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_step_filter }
|
||||||
|
|
||||||
|
chill.person.export.filter_origin:
|
||||||
|
class: Chill\PersonBundle\Export\Filter\OriginFilter
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: accompanyingcourse_origin_filter }
|
||||||
|
|
||||||
chill.person.export.aggregator_nationality:
|
chill.person.export.aggregator_nationality:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator
|
class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator
|
||||||
|
@ -390,6 +390,10 @@ Filter by step: Filtrer par statut du parcours
|
|||||||
Accepted steps: Statuts
|
Accepted steps: Statuts
|
||||||
"Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%"
|
"Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%"
|
||||||
|
|
||||||
|
Filter by origin: Filtrer par origine du parcours
|
||||||
|
Accepted origins: Origines
|
||||||
|
"Filtered by origins: only %origin%": "Filtré par origine du parcours: uniquement %origin%"
|
||||||
|
|
||||||
## aggregators
|
## aggregators
|
||||||
Group people by nationality: Aggréger les personnes par nationalités
|
Group people by nationality: Aggréger les personnes par nationalités
|
||||||
Group by level: Grouper par niveau
|
Group by level: Grouper par niveau
|
||||||
|
Loading…
x
Reference in New Issue
Block a user