/** * Get the menu data to be passed to the menu->add function * * Lavary Menu requires an array of data to be passed to the menu->add() * function call. * * @param MenuModel $menuModel * @return array */ protected function getMenuData(MenuModel $menuModel) { // Menu headers only have one class and no link. if ($menuModel->isRoot()) { return ['class' => 'header']; } $menu_data = array(); // Provide a route if there is one in the table otherwise provide a URL. if (!empty($menuModel->route)) { $menu_data['route'] = $menuModel->route; } elseif (!empty($menuModel->url)) { $menu_data['url'] = $menuModel->url; } // If this node has children, make it a treeview if (!$menuModel->isLeaf()) { $menu_data['class'] = 'treeview'; } return $menu_data; }