logic added to only keep youngest descendant. works for issue, seems not to for action

This commit is contained in:
Julie Lenaerts 2022-03-03 16:24:37 +01:00
parent d0772fc306
commit 4ef2274803

View File

@ -229,7 +229,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
public function addSocialAction(SocialAction $socialAction): self 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; $this->socialActions[] = $socialAction;
} }
@ -238,7 +249,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
public function addSocialIssue(SocialIssue $socialIssue): self 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; $this->socialIssues[] = $socialIssue;
} }