children = new ArrayCollection(); $this->socialActions = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getParent(): ?self { return $this->parent; } public function hasParent(): bool { return $this->parent !== null; } public function setParent(?self $parent): self { $this->parent = $parent; return $this; } /** * @return Collection|self[] */ public function getChildren(): Collection { return $this->children; } public function addChild(self $child): self { if (!$this->children->contains($child)) { $this->children[] = $child; $child->setParent($this); } return $this; } public function removeChild(self $child): self { if ($this->children->removeElement($child)) { // set the owning side to null (unless already changed) if ($child->getParent() === $this) { $child->setParent(null); } } 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 getDesactivationDate(): ?\DateTimeInterface { return $this->desactivationDate; } public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self { $this->desactivationDate = $desactivationDate; return $this; } public function getTitle(): array { return $this->title; } public function setTitle(array $title): self { $this->title = $title; return $this; } /** * @return Collection|SocialAction[] */ public function getSocialActions(): Collection { return $this->socialActions; } public function addSocialAction(SocialAction $socialAction): self { if (!$this->socialActions->contains($socialAction)) { $this->socialActions[] = $socialAction; $socialAction->setSocialIssue($this); } return $this; } public function removeSocialAction(SocialAction $socialAction): self { if ($this->socialActions->removeElement($socialAction)) { // set the owning side to null (unless already changed) if ($socialAction->getSocialIssue() === $this) { $socialAction->setSocialIssue(null); } } return $this; } /** * @return Collection|SocialAction[] All the descendant social actions of the entity */ public function getDescendantsSocialActions(): Collection { $descendantsSocialActions = new ArrayCollection(); foreach ($this->getSocialActions() as $socialAction) { foreach ($socialAction->getDescendantsWithThis() as $descendant) { if(! $descendantsSocialActions->contains($descendant)) { $descendantsSocialActions->add($descendant); } } } return $descendantsSocialActions; } /** * @return Collection|SocialAction[] All the descendant social actions of all * the descendants of the entity */ public function getRecursiveSocialActions(): Collection { $recursiveSocialActions = new ArrayCollection(); foreach ($this->getDescendantsWithThis() as $socialIssue) { foreach ($socialIssue->getDescendantsSocialActions() as $descendant) { if(! $recursiveSocialActions->contains($descendant)) { $recursiveSocialActions->add($descendant); } } } return $recursiveSocialActions; } }