protected function renderChildren(NodeInterface $node) { $return = null; foreach ($node->getChildren() as $child) { $return .= $child->render(); } return $return; }
public function visit(NodeInterface $node) { $nodes = [$node]; foreach ($node->getChildren() as $child) { $nodes = array_merge($nodes, $child->accept($this)); } return $nodes; }
/** * {@inheritdoc} */ public function removeChild(NodeInterface $child) { foreach ($this->children as $key => $myChild) { if ($child == $myChild) { unset($this->children[$key]); } } $this->children = array_values($this->children); $child->setParent(null); return $this; }
/** * {@inheritdoc} */ public function visit(NodeInterface $node) { if ($node->isLeaf()) { return [$node]; } $yield = []; foreach ($node->getChildren() as $child) { $yield = array_merge($yield, $child->accept($this)); } return $yield; }
/** * @param NodeInterface $node * @return Node|null */ public function visit(NodeInterface $node) { $currAc = $node->getValue(); if ($currAc instanceof Account && $currAc->getId() == $this->valueToFind) { return $node; } foreach ($node->getChildren() as $child) { /** @noinspection PhpVoidFunctionResultUsedInspection */ $found = $child->accept($this); if (!is_null($found)) { return $found; } } return null; }
private function _removeDescendants(NodeInterface $node) { /** @var NodeInterface $descendantNode */ foreach ($node->getDescendants() as $descendantNode) { if ($descendantNode->getId() || $this->_idExists($descendantNode->getId())) { unset($this->nodes[$descendantNode->getId()]); } } }
protected function renderLink(NodeInterface $node) { return $node->build(); }