From f09870931c7f8b3e945f7e52f2007b0839a0f384 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 22 Mar 2022 13:45:20 +0100 Subject: [PATCH] switch to using getDescendantsWithThis() --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 13 +++++-------- .../Entity/SocialWork/SocialAction.php | 2 +- .../Entity/SocialWork/SocialIssue.php | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index db16ac9f6..ac67a73e4 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -230,7 +230,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { - $descendants = $socialAction->getDescendants(); + $descendants = $socialAction->getDescendantsWithThis(); if (count($descendants) > 0) { foreach ($descendants as $d) { @@ -240,16 +240,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } } } - if (!$this->socialActions->contains($socialAction)) { - $this->socialActions[] = $socialAction; - } + $this->socialActions[] = $socialAction; return $this; } public function addSocialIssue(SocialIssue $socialIssue): self { - $descendants = $socialIssue->getDescendants(); + $descendants = $socialIssue->getDescendantsWithThis(); if (count($descendants) > 0) { foreach ($descendants as $d) { @@ -260,9 +258,8 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac } } - if (!$this->socialIssues->contains($socialIssue)) { - $this->socialIssues[] = $socialIssue; - } + $this->socialIssues[] = $socialIssue; + return $this; } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index ec5e5a8e5..01f30f140 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -169,7 +169,7 @@ class SocialAction } /** - * @return Collection|self[] All the descendants with the current entity (this) + * @return Collection|self[] All the descendants including the current entity (this) */ public function getDescendantsWithThis(): Collection { diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index c735c0132..fb277f56c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -202,7 +202,7 @@ class SocialIssue } /** - * @return Collection|self[] All the descendants with the current entity (this) + * @return Collection|self[] All the descendants including the current entity (this) */ public function getDescendantsWithThis(): Collection {