70 private $menuItemChecker;
75 private $anchorRenderer;
99 \
Magento\Backend\Model\
Menu\Filter\IteratorFactory $iteratorFactory,
100 \
Magento\Backend\Model\Auth\Session $authSession,
102 \
Magento\Framework\Locale\ResolverInterface $localeResolver,
106 \
Magento\Framework\
App\Route\ConfigInterface $routeConfig =
null 109 $this->_iteratorFactory = $iteratorFactory;
110 $this->_authSession = $authSession;
111 $this->_menuConfig = $menuConfig;
112 $this->_localeResolver = $localeResolver;
113 $this->menuItemChecker = $menuItemChecker;
114 $this->anchorRenderer = $anchorRenderer;
115 $this->routeConfig = $routeConfig ?:
117 ->get(\
Magento\Framework\
App\Route\ConfigInterface::class);
118 parent::__construct($context,
$data);
128 parent::_construct();
129 $this->setCacheTags([self::CACHE_TAGS]);
151 return $menuItem->hasChildren()
152 ?
'onmouseover="Element.addClassName(this,\'over\')" onmouseout="Element.removeClassName(this,\'over\')"' 165 $isLast = 0 == $level && (bool)$this->
getMenuModel()->isLast($menuItem) ?
'last' :
'';
166 $isItemActive = $this->menuItemChecker->isItemActive(
170 ) ?
'_current _active' :
'';
174 ($menuItem->hasChildren() ?
'parent' :
'') .
191 return $this->_iteratorFactory->create([
'iterator' => $menu->getIterator()]);
202 $html = preg_replace_callback(
203 '#' . \
Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME .
'/\$([^\/].*)/([^\/].*)/([^\$].*)\$#U',
204 [$this,
'_callbackSecretKey'],
219 $routeId = $this->routeConfig->getRouteByFrontName($match[1]);
220 return \Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME .
'/' . $this->_url->getSecretKey(
221 $routeId ?: $match[1],
247 $this->_authSession->getUser()->getId(),
248 $this->_localeResolver->getLocale(),
251 $newCacheKeyInfo = $this->getAdditionalCacheKeyInfo();
252 if (is_array($newCacheKeyInfo) && !empty($newCacheKeyInfo)) {
253 $cacheKeyInfo = array_merge($cacheKeyInfo, $newCacheKeyInfo);
255 return $cacheKeyInfo;
265 return $this->_menuConfig->getMenu();
275 public function renderMenu($menu, $level = 0)
277 $output =
'<ul ' . (0 == $level ?
'id="nav" role="menubar"' :
'') .
' >';
288 ) .
'role="menuitem">';
292 if ($menuItem->hasChildren()) {
293 $output .= $this->renderMenu($menuItem->getChildren(), $level + 1);
308 protected function _countItems(
$items)
313 if (
$item->hasChildren()) {
314 $total += $this->_countItems(
$item->getChildren());
330 $total = $this->_countItems(
$items);
331 if ($total <= $limit) {
334 $result[] = [
'total' => $total,
'max' => ceil($total / ceil($total / $limit))];
337 $place = $this->_countItems(
$item->getChildren()) + 1;
348 $result[] = [
'place' => $place,
'colbrake' => $colbrake];
365 if (!$menuItem->hasChildren()) {
368 $output .=
'<div class="submenu"' . ($level == 0 && isset(
$id) ?
' aria-labelledby="' .
$id .
'"' :
'') .
'>';
370 if ($level == 0 && $limit) {
371 $colStops = $this->
_columnBrake($menuItem->getChildren(), $limit);
373 $output .=
'<a href="#" class="action-close _close" data-role="close-submenu"></a>';
376 $output .= $this->renderNavigation($menuItem->getChildren(), $level + 1, $limit, $colStops);
392 public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
395 $outputStart =
'<ul ' . (0 == $level ?
'id="nav" role="menubar"' :
'role="menu"') .
' >';
400 $menuId = $menuItem->getId();
401 $itemName = substr($menuId, strrpos($menuId,
'::') + 2);
402 $itemClass = str_replace(
'_',
'-', strtolower($itemName));
404 if (is_array($colBrakes)
406 && $colBrakes[$itemPosition][
'colbrake']
407 && $itemPosition != 1
409 $output .=
'</ul></li><li class="column"><ul role="menu">';
414 $anchor = $this->anchorRenderer->renderAnchor($this->
getActiveItemModel(), $menuItem, $level);
417 . ($level == 0 ?
'" id="' .
$id .
'" aria-haspopup="true' :
'')
418 .
'" role="menu-item">' . $anchor . $subMenu .
'</li>';
422 if (is_array($colBrakes) && count($colBrakes) && $limit) {
423 $output =
'<li class="column"><ul role="menu">' .
$output .
'</ul></li>';
426 return $outputStart .
$output .
'</ul>';
436 if ($this->_activeItemModel ===
null) {
437 $this->_activeItemModel = $this->
getMenuModel()->get($this->getActive());
438 if (
false == $this->_activeItemModel instanceof \
Magento\Backend\Model\
Menu\
Item) {
439 $this->_activeItemModel =
false;
getJsId($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
elseif(isset( $params[ 'redirect_parent']))
getUiId($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
escapeHtml($data, $allowedTags=null)