review: fix stuffs on socialAction and socialIssue filters:

* filters call static entity method
* add renderString option to manage add_children
* add tests on new entity method getDescendantsWithThisFor..()
* rename function in repository
* rename 'Select2..' classes by 'Pick..' and replace all occurences
This commit is contained in:
2022-10-17 09:52:29 +02:00
parent 71f989f00e
commit 32ddc5465c
22 changed files with 244 additions and 151 deletions

View File

@@ -227,6 +227,23 @@ class SocialAction
return $descendants;
}
/**
* @param Collection|SocialAction[] $socialActions
* @return Collection
*/
public static function getDescendantsWithThisForActions($socialActions): Collection
{
$unique = [];
foreach ($socialActions as $action) {
foreach ($action->getDescendantsWithThis() as $child) {
$unique[spl_object_hash($child)] = $child;
}
}
return new ArrayCollection(array_values($unique));
}
public function getEvaluations(): Collection
{
return $this->evaluations;
@@ -278,6 +295,11 @@ class SocialAction
return $this->getParent() instanceof self;
}
public function hasChildren(): bool
{
return 0 < $this->getChildren()->count();
}
/**
* Recursive method which return true if the current $action
* is a descendant of the $action given in parameter.