/** * Count All Subnavigation Items * * @param \Magento\Backend\Model\Menu $items * @return int */ protected function _countItems($items) { $total = $items->count(); foreach ($items as $item) { /** @var $item \Magento\Backend\Model\Menu\Item */ if ($item->hasChildren()) { $total += $this->_countItems($item->getChildren()); } } return $total; }
/** * Check whether item has subnodes * * @return bool */ public function hasChildren() { return !is_null($this->_submenu) && (bool) $this->_submenu->count(); }