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