diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 0a344236c..f80d4ab86 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -229,7 +229,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialAction(SocialAction $socialAction): self { - if (!$this->socialActions->contains($socialAction)) { + $descendants = $socialAction->getDescendants(); + $inCollection = false; + + if(null != $descendants) { + foreach ($descendants as $d) { + $inCollection = $this->socialActions->contains($d); + } + } else { + $inCollection = $this->socialActions->contains($socialAction); + } + + if(!$inCollection) { $this->socialActions[] = $socialAction; } @@ -238,7 +249,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac public function addSocialIssue(SocialIssue $socialIssue): self { - if (!$this->socialIssues->contains($socialIssue)) { + $descendants = $socialIssue->getDescendants(); + $inCollection = false; + + if(null != $descendants) { + foreach ($descendants as $d) { + $inCollection = $this->socialIssues->contains($d); + } + } else { + $inCollection = $this->socialIssues->contains($socialIssue); + } + + if(!$inCollection) { $this->socialIssues[] = $socialIssue; }