fix logic in activity entity

This commit is contained in:
Julie Lenaerts 2022-03-04 12:06:53 +01:00
parent 432b105be5
commit f35479e4d2

View File

@ -230,18 +230,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
public function addSocialAction(SocialAction $socialAction): self public function addSocialAction(SocialAction $socialAction): self
{ {
$descendants = $socialAction->getDescendants(); $descendants = $socialAction->getDescendants();
$inCollection = false;
if(null != $descendants) { if(count($descendants) > 0) {
foreach ($descendants as $d) { foreach ($descendants as $d) {
$inCollection = $this->socialActions->contains($d); $inCollection = $this->socialActions->contains($d);
if ($inCollection) {
return $this;
}
} }
} else { } else {
$inCollection = $this->socialActions->contains($socialAction); if (!$this->socialActions->contains($socialAction)) {
} $this->socialActions[] = $socialAction;
};
if(!$inCollection) {
$this->socialActions[] = $socialAction;
} }
return $this; return $this;
@ -250,18 +250,18 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
public function addSocialIssue(SocialIssue $socialIssue): self public function addSocialIssue(SocialIssue $socialIssue): self
{ {
$descendants = $socialIssue->getDescendants(); $descendants = $socialIssue->getDescendants();
$inCollection = false;
if(null != $descendants) { if(count($descendants) > 0) {
foreach ($descendants as $d) { foreach ($descendants as $d) {
$inCollection = $this->socialIssues->contains($d); $inCollection = $this->socialIssues->contains($d);
if ($inCollection) {
return $this;
}
} }
} else { } else {
$inCollection = $this->socialIssues->contains($socialIssue); if (!$this->socialIssues->contains($socialIssue)) {
} $this->socialIssues[] = $socialIssue;
};
if(!$inCollection) {
$this->socialIssues[] = $socialIssue;
} }
return $this; return $this;