public function renderMenuItem(Menu $item, $variables = [], $menuBranch = [])
{
$itemGroupStart = "";
$itemGroupContent = "";
$itemGroupEnd = "";
$itemContent = "";
if ($item->enabled) {
$variables = $this->getVariables($item, $variables);
$bActive = in_array($item->name, $menuBranch);
$bHasChildren = $item->children->count() ? true : false;
$bIsSeparator = $item->separator ? true : false;
if ($bHasChildren) {
if ($bActive) {
$itemGroupStart = $this->replaceVars($this->MENU_GROUP_START_OPENED, $variables);
} else {
$itemGroupStart = $this->replaceVars($this->MENU_GROUP_START_CLOSED, $variables);
}
$children = $item->children;
foreach ($children as $child) {
$itemGroupContent .= $this->renderMenuItem($child, $variables, $menuBranch);
}
$itemGroupEnd = $this->replaceVars($this->MENU_GROUP_END, $variables);
if ("" != $itemGroupContent) {
$itemContent = $itemGroupStart . $itemGroupContent . $itemGroupEnd;
}
} elseif ($bIsSeparator) {
$itemContent .= $this->replaceVars($this->MENU_ITEM_SEPARATOR, $variables);
} else {
if ($bActive) {
$itemContent .= $this->replaceVars($this->MENU_ITEM_ACTIVE, $variables);
} else {
$itemContent .= $this->replaceVars($this->MENU_ITEM_INACTIVE, $variables);
}
}
}
return $itemContent;
}