Descendants for socialActions & Issues

This commit is contained in:
Marc Ducobu
2021-06-04 12:14:31 +02:00
parent 330234981c
commit bb71b9f908
4 changed files with 141 additions and 12 deletions

View File

@@ -824,20 +824,41 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
}
/**
* List of all the social actions of the accompanyingPeriod
* i.e. social actions From social issues from the accompanyingPeriod
* @return Collection|SocialIssues[] All social issues and their descendants
*/
public function getSocialActions(): Collection
public function getRecursiveSocialIssues(): Collection
{
$ret = new ArrayCollection();
$recursiveSocialIssues = new ArrayCollection();
$this->socialIssues->forAll(function($key, $socialIssue) use ($ret) {
$socialIssue->getSocialActions()->forAll(function($key, $socialAction) use ($ret) {
$ret->add($socialAction);
});
});
foreach( $this->socialIssues as $socialIssue) {
foreach ($socialIssue->getDescendantsWithThis() as $descendant) {
if(! $recursiveSocialIssues->contains($descendant)) {
$recursiveSocialIssues->add($descendant);
}
}
}
return $ret;
return $recursiveSocialIssues;
}
/**
* @return Collection|SocialAction[] All the descendant social actions of all
* the descendants of the entity
*/
public function getRecursiveSocialActions(): Collection
{
$recursiveSocialActions = new ArrayCollection();
foreach( $this->socialIssues as $socialIssue) {
foreach ($socialIssue->getRecursiveSocialActions() as $descendant) {
if(! $recursiveSocialActions->contains($descendant)) {
$recursiveSocialActions->add($descendant);
}
}
}
return $recursiveSocialActions;
}
/**