81 lines
2.6 KiB
PHP
81 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace Edeclic\Theme\Block\Html;
|
|
|
|
class Topmenu extends \Magento\Theme\Block\Html\Topmenu
|
|
{
|
|
|
|
/**
|
|
* Recursively generates top menu html from data that is specified in $menuTree
|
|
*
|
|
* @param \Magento\Framework\Data\Tree\Node $menuTree
|
|
* @param string $childrenWrapClass
|
|
* @param int $limit
|
|
* @param array $colBrakes
|
|
* @return string
|
|
*
|
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
*/
|
|
protected function _getHtml(
|
|
\Magento\Framework\Data\Tree\Node $menuTree,
|
|
$childrenWrapClass,
|
|
$limit,
|
|
$colBrakes = []
|
|
) {
|
|
$html = '';
|
|
|
|
$children = $menuTree->getChildren();
|
|
$parentLevel = $menuTree->getLevel();
|
|
$childLevel = $parentLevel === null ? 0 : $parentLevel + 1;
|
|
|
|
$counter = 1;
|
|
$itemPosition = 1;
|
|
$childrenCount = $children->count();
|
|
|
|
$parentPositionClass = $menuTree->getPositionClass();
|
|
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
|
|
|
|
foreach ($children as $child) {
|
|
$child->setLevel($childLevel);
|
|
$child->setIsFirst($counter == 1);
|
|
$child->setIsLast($counter == $childrenCount);
|
|
$child->setPositionClass($itemPositionClassPrefix . $counter);
|
|
|
|
$outermostClassCode = '';
|
|
$outermostClass = $menuTree->getOutermostClass();
|
|
|
|
if ($childLevel == 0 && $outermostClass) {
|
|
$outermostClassCode = ' class="' . $outermostClass . '" ';
|
|
$child->setClass($outermostClass);
|
|
}
|
|
|
|
if (count($colBrakes) && $colBrakes[$counter]['colbrake']) {
|
|
$html .= '</ul></li><li class="column"><ul>';
|
|
}
|
|
$fleche = '';
|
|
if($child->hasChildren()){
|
|
$fleche = '<i class="fa fa-angle-down" aria-hidden="true"></i>';
|
|
}
|
|
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
|
|
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml(
|
|
$child->getName()
|
|
) . '</span></a>'. $fleche . $this->_addSubMenu(
|
|
$child,
|
|
$childLevel,
|
|
$childrenWrapClass,
|
|
$limit
|
|
) . '</li>';
|
|
|
|
$itemPosition++;
|
|
$counter++;
|
|
}
|
|
|
|
if (count($colBrakes) && $limit) {
|
|
$html = '<li class="column"><ul>' . $html . '</ul></li>';
|
|
}
|
|
|
|
return $html;
|
|
}
|
|
|
|
} |