mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Features: [export] Show also SocialIssue in the By Social Action aggregator
This commit is contained in:
parent
61f44396c5
commit
91e3588e76
@ -14,8 +14,11 @@ namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
|||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||||
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use LogicException;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
|
|
||||||
@ -25,12 +28,20 @@ final class ActionTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
private SocialActionRepository $socialActionRepository;
|
private SocialActionRepository $socialActionRepository;
|
||||||
|
|
||||||
|
private SocialIssueRender $socialIssueRender;
|
||||||
|
|
||||||
|
private SocialIssueRepository $socialIssueRepository;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SocialActionRepository $socialActionRepository,
|
SocialActionRepository $socialActionRepository,
|
||||||
SocialActionRender $actionRender
|
SocialActionRender $actionRender,
|
||||||
|
SocialIssueRender $socialIssueRender,
|
||||||
|
SocialIssueRepository $socialIssueRepository
|
||||||
) {
|
) {
|
||||||
$this->socialActionRepository = $socialActionRepository;
|
$this->socialActionRepository = $socialActionRepository;
|
||||||
$this->actionRender = $actionRender;
|
$this->actionRender = $actionRender;
|
||||||
|
$this->socialIssueRender = $socialIssueRender;
|
||||||
|
$this->socialIssueRepository = $socialIssueRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole(): ?string
|
public function addRole(): ?string
|
||||||
@ -44,8 +55,15 @@ final class ActionTypeAggregator implements AggregatorInterface
|
|||||||
$qb->leftJoin('acpw.socialAction', 'acpwsocialaction');
|
$qb->leftJoin('acpw.socialAction', 'acpwsocialaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('acpwsocialaction.id as action_type_aggregator');
|
if (!in_array('acpwsocialissue', $qb->getAllAliases(), true)) {
|
||||||
$qb->addGroupBy('action_type_aggregator');
|
$qb->leftJoin('acpwsocialaction.issue', 'acpwsocialissue');
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->addSelect('acpwsocialissue.id as social_action_type_aggregator')
|
||||||
|
->addSelect('acpwsocialaction.id as action_type_aggregator')
|
||||||
|
->addGroupBy('action_type_aggregator')
|
||||||
|
->addGroupBy('social_action_type_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
@ -60,24 +78,41 @@ final class ActionTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
return function ($value): string {
|
switch ($key) {
|
||||||
if ('_header' === $value) {
|
case 'action_type_aggregator':
|
||||||
return 'Social Action Type';
|
return function ($value): string {
|
||||||
}
|
if ('_header' === $value) {
|
||||||
|
return 'Social Action Type';
|
||||||
|
}
|
||||||
|
|
||||||
if (null === $value) {
|
if (null === $value || null === $sa = $this->socialActionRepository->find($value)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sa = $this->socialActionRepository->find($value);
|
return $this->actionRender->renderString($sa, []);
|
||||||
|
};
|
||||||
|
|
||||||
return $this->actionRender->renderString($sa, []);
|
case 'social_action_type_aggregator':
|
||||||
};
|
return function ($value): string {
|
||||||
|
if ('_header' === $value) {
|
||||||
|
return 'Social Issue';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $value || null === $si = $this->socialIssueRepository->find($value)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->socialIssueRender->renderString($si, []);
|
||||||
|
};
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new LogicException('this key is not supported: ' . $key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
public function getQueryKeys($data)
|
||||||
{
|
{
|
||||||
return ['action_type_aggregator'];
|
return ['social_action_type_aggregator', 'action_type_aggregator'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user