' . htmlspecialchars($node->getLabel());
if ($recursive && $node->hasChildNodes()) {
$this->recursionLevel++;
$code .= $this->renderNodeCollection($node->getChildNodes());
$this->recursionLevel--;
}
$code .= '';
return $code;
}
/**
* Renders a node collection recursive or just a single instance
*
* @param bool $recursive
* @return string
*/
public function renderTree(AbstractTree $tree, $recursive = true)
{
$this->recursionLevel = 0;
$code = '';
// @todo: this doc block is a hack, as it needs to be a TreeReprsentationNode
/** @var TreeRepresentationNode $rootNode */
$rootNode = $tree->getRoot();
$code .= $this->renderNode($rootNode, $recursive);
$code .= '
';
return $code;
}
/**
* Renders a tree recursively or just a single instance
*
* @param bool $recursive
* @return string
*/
public function renderNodeCollection(TreeNodeCollection $collection, $recursive = true)
{
$code = '';
foreach ($collection as $node) {
$code .= $this->renderNode($node, $recursive);
}
$code .= '
';
return $code;
}
}