parent
a408636923
commit
ed6da19876
|
@ -36,6 +36,13 @@ class NavigationItem implements IteratorAggregate
|
|||
*/
|
||||
protected $active;
|
||||
|
||||
/**
|
||||
* The CSS class used for the outer li element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cssClass;
|
||||
|
||||
/**
|
||||
* This item's priority
|
||||
*
|
||||
|
@ -200,6 +207,29 @@ class NavigationItem implements IteratorAggregate
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CSS class used for the outer li element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCssClass()
|
||||
{
|
||||
return $this->cssClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CSS class to use for the outer li element
|
||||
*
|
||||
* @param string $class
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCssClass($class)
|
||||
{
|
||||
$this->cssClass = (string) $class;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this item's priority
|
||||
*
|
||||
|
|
|
@ -304,10 +304,10 @@ class NavigationRenderer implements RecursiveIterator, NavigationRendererInterfa
|
|||
*/
|
||||
public function beginItemMarkup(NavigationItem $item)
|
||||
{
|
||||
$cssClass = array(static::CSS_CLASS_ITEM);
|
||||
$cssClasses = array(static::CSS_CLASS_ITEM);
|
||||
|
||||
if ($item->hasChildren() && $item->getChildren()->getLayout() === Navigation::LAYOUT_DROPDOWN) {
|
||||
$cssClass[] = static::CSS_CLASS_DROPDOWN;
|
||||
$cssClasses[] = static::CSS_CLASS_DROPDOWN;
|
||||
$item
|
||||
->setAttribute('class', static::CSS_CLASS_DROPDOWN_TOGGLE)
|
||||
->setIcon(static::DROPDOWN_TOGGLE_ICON)
|
||||
|
@ -315,12 +315,16 @@ class NavigationRenderer implements RecursiveIterator, NavigationRendererInterfa
|
|||
}
|
||||
|
||||
if ($item->getActive()) {
|
||||
$cssClass[] = static::CSS_CLASS_ACTIVE;
|
||||
$cssClasses[] = static::CSS_CLASS_ACTIVE;
|
||||
}
|
||||
|
||||
if ($cssClass = $item->getCssClass()) {
|
||||
$cssClasses[] = $cssClass;
|
||||
}
|
||||
|
||||
$content = sprintf(
|
||||
'<li class="%s">',
|
||||
join(' ', $cssClass)
|
||||
join(' ', $cssClasses)
|
||||
);
|
||||
return $content;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue