mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
[export] fix data type from form: either collection or array
This commit is contained in:
@@ -16,6 +16,7 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Form\Type\PickSocialIssueType;
|
||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
@@ -50,7 +51,9 @@ class SocialIssueFilter implements FilterInterface
|
||||
$qb->andWhere($clause)
|
||||
->setParameter(
|
||||
'socialissues',
|
||||
SocialIssue::getDescendantsWithThisForIssues($data['accepted_socialissues']->toArray())
|
||||
SocialIssue::getDescendantsWithThisForIssues(
|
||||
$data['accepted_socialissues'] instanceof Collection ? $data['accepted_socialissues']->toArray() : $data['accepted_socialissues']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
@@ -105,7 +106,7 @@ class UserJobFilter implements FilterInterface
|
||||
', ',
|
||||
array_map(
|
||||
fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
|
||||
$data['jobs']->toArray()
|
||||
$data['jobs'] instanceof Collection ? $data['jobs']->toArray() : $data['jobs']
|
||||
)
|
||||
),
|
||||
],
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
@@ -104,7 +105,7 @@ class UserScopeFilter implements FilterInterface
|
||||
', ',
|
||||
array_map(
|
||||
fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
|
||||
$data['scopes']->toArray()
|
||||
$data['scopes'] instanceof Collection ? $data['scopes']->toArray() : $data['scopes']
|
||||
)
|
||||
),
|
||||
],
|
||||
|
@@ -52,6 +52,7 @@ final class SocialIssueFilterTest extends AbstractFilterTest
|
||||
->getResult();
|
||||
|
||||
yield ['accepted_socialissues' => new ArrayCollection($array)];
|
||||
yield ['accepted_socialissues' => $array];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
|
@@ -52,6 +52,11 @@ final class UserJobFilterTest extends AbstractFilterTest
|
||||
'jobs' => new ArrayCollection($jobs),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
|
||||
yield [
|
||||
'jobs' => $jobs,
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
|
@@ -53,6 +53,10 @@ final class UserScopeFilterTest extends AbstractFilterTest
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'scopes' => new ArrayCollection($scopes),
|
||||
],
|
||||
[
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'scopes' => $scopes,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user