children = new ArrayCollection(); } public function addChildren(ClosingMotive $child): ClosingMotive { if ($this->children->contains($child)) { return $this; } $this->children->add($child); $child->setParent($this); return $this; } public function getChildren(): Collection { return $this->children; } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Get name. * * @return array */ public function getName() { return $this->name; } public function getOrdering(): float { return $this->ordering; } /** * @return ClosingMotive */ public function getParent() { return $this->parent; } public function hasParent(): bool { return null !== $this->parent; } public function isActive(): bool { return $this->active; } public function isChild(): bool { return null !== $this->parent; } public function isLeaf(): bool { return $this->children->count() === 0; } public function isParent(): bool { return $this->children->count() > 0; } public function removeChildren(ClosingMotive $child): ClosingMotive { if ($this->children->removeElement($child)) { $child->setParent(null); } return $this; } /** * @return $this */ public function setActive(bool $active) { $this->active = $active; if (false === $this->active) { foreach ($this->getChildren() as $child) { $child->setActive(false); } } return $this; } public function setChildren(Collection $children): ClosingMotive { $this->children = $children; return $this; } /** * Set name. * * @param array $name * * @return ClosingMotive */ public function setName($name) { $this->name = $name; return $this; } /** * @return $this */ public function setOrdering(float $ordering) { $this->ordering = $ordering; return $this; } public function setParent(?ClosingMotive $parent): ClosingMotive { $this->parent = $parent; if (null !== $parent) { //$parent->addChildren($this); } return $this; } }