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

@@ -139,6 +139,41 @@ class SocialAction
return $this;
}
/**
* @return Collection|self[] All the descendants (children, children of children, ...)
*/
public function getDescendants(): Collection
{
$descendants = new ArrayCollection();
foreach ($this->getChildren() as $child) {
if(! $descendants->contains($child)) {
$descendants->add($child);
foreach($child->getDescendants() as $descendantsOfChild) {
if(! $descendants->contains($descendantsOfChild)) {
$descendants->add($descendantsOfChild);
}
}
}
}
return $descendants;
}
/**
* @return Collection|self[] All the descendants with the current entity (this)
*/
public function getDescendantsWithThis(): Collection
{
$descendants = $this->getDescendants();
if(! $descendants->contains($this)) {
$descendants->add($this);
}
return $descendants;
}
public function getDefaultNotificationDelay(): ?\DateInterval
{
return $this->defaultNotificationDelay;