mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Refactor BySocialIssueFilter to enhance normalization logic
Added ExportDataNormalizerTrait to streamline data normalization and denormalization processes. Updated constructor to inject dependencies for SocialIssueRepository and NormalizerInterface, improving modularity and maintainability. Adjusted form data normalization methods to utilize the new utilities.
This commit is contained in:
parent
e89f5e4713
commit
9f32b5ac48
@ -12,17 +12,21 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
namespace Chill\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Export\Declarations;
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Export\ExportDataNormalizerTrait;
|
||||||
use Chill\MainBundle\Export\ExportGenerationContext;
|
use Chill\MainBundle\Export\ExportGenerationContext;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
use Chill\PersonBundle\Form\Type\PickSocialIssueType;
|
use Chill\PersonBundle\Form\Type\PickSocialIssueType;
|
||||||
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class BySocialIssueFilter implements FilterInterface
|
class BySocialIssueFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
public function __construct(private readonly SocialIssueRender $issueRender) {}
|
use ExportDataNormalizerTrait;
|
||||||
|
|
||||||
|
public function __construct(private readonly SocialIssueRender $issueRender, private readonly SocialIssueRepository $issueRepository) {}
|
||||||
|
|
||||||
public function addRole(): ?string
|
public function addRole(): ?string
|
||||||
{
|
{
|
||||||
@ -63,12 +67,12 @@ class BySocialIssueFilter implements FilterInterface
|
|||||||
|
|
||||||
public function normalizeFormData(array $formData): array
|
public function normalizeFormData(array $formData): array
|
||||||
{
|
{
|
||||||
return ['accepted_socialissues' => $formData['accepted_socialissues']];
|
return ['accepted_socialissues' => $this->normalizeDoctrineEntity($formData['accepted_socialissues'])];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function denormalizeFormData(array $formData, int $fromVersion): array
|
public function denormalizeFormData(array $formData, int $fromVersion): array
|
||||||
{
|
{
|
||||||
return ['accepted_socialissues' => $formData['accepted_socialissues']];
|
return ['accepted_socialissues' => $this->denormalizeDoctrineEntity($formData['accepted_socialissues'], $this->issueRepository)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user