/**
* Render a toolbar.
*
* @param array $options The options of toolbar.
*
* @return string HTML for the toolbar.
*
* @throws \Exception
* @since 1.5
*/
public function render(array $options = [])
{
$html = [];
$isChild = !empty($options['is_child']);
// Start toolbar div.
if (!$isChild) {
$layout = new FileLayout('joomla.toolbar.containeropen');
$html[] = $layout->render(['id' => $this->_name]);
}
$len = count($this->_bar);
// Render each button in the toolbar.
foreach ($this->_bar as $i => $button) {
if ($button instanceof ToolbarButton) {
// Child dropdown only support new syntax
$button->setOption('is_child', $isChild);
$button->setOption('is_first_child', $i === 0);
$button->setOption('is_last_child', $i === $len - 1);
$html[] = $button->render();
} else {
$html[] = $this->renderButton($button);
}
}
// End toolbar div.
if (!$isChild) {
$layout = new FileLayout('joomla.toolbar.containerclose');
$html[] = $layout->render([]);
}
return implode('', $html);
}