From c79c39b562a0f9327fd73317fc701ccb8108239a Mon Sep 17 00:00:00 2001 From: LenaertsJ Date: Wed, 5 Nov 2025 08:51:47 +0000 Subject: [PATCH] Fix: display also social actions linked to parents of the selected social issue --- .../unreleased/Fixed-20251029-124355.yaml | 6 ++++++ .../Entity/SocialWork/SocialIssue.php | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 .changes/unreleased/Fixed-20251029-124355.yaml diff --git a/.changes/unreleased/Fixed-20251029-124355.yaml b/.changes/unreleased/Fixed-20251029-124355.yaml new file mode 100644 index 000000000..e032e7703 --- /dev/null +++ b/.changes/unreleased/Fixed-20251029-124355.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: 'Fix: display also social actions linked to parents of the selected social issue' +time: 2025-10-29T12:43:55.008647232+01:00 +custom: + Issue: "451" + SchemaChange: No schema change diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 02c38a60a..66189642e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -122,6 +122,8 @@ class SocialIssue * get all the ancestors of the social issue. * * @param bool $includeThis if the array in the result must include the present SocialIssue + * + * @return list */ public function getAncestors(bool $includeThis = true): array { @@ -176,7 +178,7 @@ class SocialIssue } /** - * @return Collection|SocialAction[] All the descendant social actions of the entity + * @return Collection All the descendant social actions of the entity */ public function getDescendantsSocialActions(): Collection { @@ -239,18 +241,23 @@ class SocialIssue } /** - * @return Collection All the descendant social actions of all - * the descendants of the entity + * @return Collection All the social actions of the entity, it's + * the descendants and it's parents */ public function getRecursiveSocialActions(): Collection { $recursiveSocialActions = new ArrayCollection(); + // Get social actions from parent issues + foreach ($this->getAncestors(false) as $ancestor) { + foreach ($ancestor->getDescendantsSocialActions() as $descendant) { + $recursiveSocialActions->add($descendant); + } + } + foreach ($this->getDescendantsWithThis() as $socialIssue) { foreach ($socialIssue->getDescendantsSocialActions() as $descendant) { - if (!$recursiveSocialActions->contains($descendant)) { - $recursiveSocialActions->add($descendant); - } + $recursiveSocialActions->add($descendant); } }