mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-29 21:46:14 +00:00
issue641: remove method to add parents socialissues (bad understanding)
This commit is contained in:
parent
6d40ef279f
commit
8d7b6fea71
@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
|||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Form\Type\Select2SocialIssueType;
|
use Chill\PersonBundle\Form\Type\Select2SocialIssueType;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
@ -57,7 +56,7 @@ class SocialIssueFilter implements FilterInterface
|
|||||||
$clause = $qb->expr()->in('acpsocialissue.id', ':socialissues');
|
$clause = $qb->expr()->in('acpsocialissue.id', ':socialissues');
|
||||||
|
|
||||||
$qb ->andWhere($clause)
|
$qb ->andWhere($clause)
|
||||||
->setParameter('socialissues', $this->addParentIssues($data['accepted_socialissues']));
|
->setParameter('socialissues', $data['accepted_socialissues']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
@ -76,7 +75,7 @@ class SocialIssueFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
$issues = [];
|
$issues = [];
|
||||||
|
|
||||||
$socialissues = $this->addParentIssues($data['accepted_socialissues']);
|
$socialissues = $data['accepted_socialissues'];
|
||||||
|
|
||||||
foreach ($socialissues as $i) {
|
foreach ($socialissues as $i) {
|
||||||
if ('null' === $i) {
|
if ('null' === $i) {
|
||||||
@ -96,40 +95,4 @@ class SocialIssueFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
return 'Filter by social issue';
|
return 'Filter by social issue';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* "Le filtre retiendra les parcours qui comportent cette problématique,
|
|
||||||
* ou une problématique parente à celles choisies.".
|
|
||||||
*
|
|
||||||
* Add parent of each socialissue selected, and remove duplicates
|
|
||||||
*
|
|
||||||
* @param $accepted_issues
|
|
||||||
*/
|
|
||||||
private function addParentIssues($accepted_issues): array
|
|
||||||
{
|
|
||||||
$array = [];
|
|
||||||
|
|
||||||
foreach ($accepted_issues as $i) {
|
|
||||||
/** @var SocialIssue $i */
|
|
||||||
if ($i->hasParent()) {
|
|
||||||
$array[] = $i->getParent();
|
|
||||||
}
|
|
||||||
$array[] = $i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->removeDuplicate($array);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function removeDuplicate(array $array): array
|
|
||||||
{
|
|
||||||
$ids = array_map(static function ($item) {
|
|
||||||
return $item->getId();
|
|
||||||
}, $array);
|
|
||||||
|
|
||||||
$unique_ids = array_unique($ids);
|
|
||||||
|
|
||||||
return array_values(
|
|
||||||
array_intersect_key($array, $unique_ids)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user