mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: share referrer aggregator
This commit is contained in:
parent
f817ca9671
commit
ed1dde4713
@ -9,11 +9,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
||||
namespace Chill\PersonBundle\Export\Aggregator;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\From;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@ -21,9 +23,14 @@ final class ReferrerAggregator implements AggregatorInterface
|
||||
{
|
||||
private UserRepository $userRepository;
|
||||
|
||||
public function __construct(UserRepository $userRepository)
|
||||
{
|
||||
private UserRender $userRender;
|
||||
|
||||
public function __construct(
|
||||
UserRepository $userRepository,
|
||||
UserRender $userRender
|
||||
) {
|
||||
$this->userRepository = $userRepository;
|
||||
$this->userRender = $userRender;
|
||||
}
|
||||
|
||||
public function addRole()
|
||||
@ -33,8 +40,21 @@ final class ReferrerAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->join('acpw.referrers', 'r');
|
||||
$qb->addSelect('r.id as referrer_aggregator');
|
||||
switch ($this->getBaseEntityAppliedOn($qb)) {
|
||||
|
||||
case 'acp':
|
||||
$qb->join('acp.user', 'u');
|
||||
$qb->addSelect('u.id AS referrer_aggregator');
|
||||
break;
|
||||
|
||||
case 'acpw':
|
||||
$qb->join('acpw.referrers', 'r');
|
||||
$qb->addSelect('r.id AS referrer_aggregator');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception("Does not apply on that base entity");
|
||||
}
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
@ -46,9 +66,9 @@ final class ReferrerAggregator implements AggregatorInterface
|
||||
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
return Declarations::ACP_SHARED;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
@ -65,17 +85,25 @@ final class ReferrerAggregator implements AggregatorInterface
|
||||
|
||||
$r = $this->userRepository->find($value);
|
||||
|
||||
return $r->getUsername();
|
||||
return $this->userRender->renderString($r, []);
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['referrer_aggregator'];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group social work actions by referrers';
|
||||
return 'Group by referrers';
|
||||
}
|
||||
|
||||
private function getBaseEntityAppliedOn(QueryBuilder $qb): string
|
||||
{
|
||||
/** @var From $from */
|
||||
$from = $qb->getDQLPart('from');
|
||||
|
||||
return $from[0]->getAlias();
|
||||
}
|
||||
}
|
@ -233,3 +233,11 @@ services:
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_intensity_aggregator }
|
||||
|
||||
chill.person.export.aggregator_referrer:
|
||||
class: Chill\PersonBundle\Export\Aggregator\ReferrerAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_referrer_aggregator }
|
||||
|
||||
|
@ -31,13 +31,6 @@ services:
|
||||
- { name: chill.export_filter, alias: social_work_actions_job_filter }
|
||||
|
||||
## AGGREGATORS
|
||||
chill.person.export.aggregator_referrer:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ReferrerAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_referrer_aggregator }
|
||||
|
||||
chill.person.export.aggregator_action_type:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator
|
||||
autowire: true
|
||||
|
@ -504,6 +504,7 @@ Filtered by active at least one day between dates: Filtrer les parcours actifs a
|
||||
Filtered by referrers: Filtrer par référent
|
||||
Accepted referrers: Référents
|
||||
"Filtered by referrer: only %referrers%": "Filtré par référent: uniquement %referrers%"
|
||||
Group by referrers: Grouper par référent
|
||||
|
||||
Filtered by opened between dates: Filtrer les parcours ouverts entre deux dates
|
||||
Date from: Date de début
|
||||
|
Loading…
x
Reference in New Issue
Block a user