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 00a6ef0598
commit 988b67bd4b

View File

@ -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;
}