예제 #1
0
    /**
     *
     * @param MenuItem $menuItem
     * @return array
     */
    public function getMenuAttributes(MenuItem $item)
    {
        // if we don't have access or this item is marked to not be shown
        if (!$item->shouldBeRendered()) {
            return;
        }

        $depth = $item->getLevel();
        $maxDepth = $item->getMaxDepth();
            
        $class = array();
        
        if ($maxDepth > 1) {
            $class[] = "deeper";
        }
        $class[] = "level_{$depth}";

        // retrieve the attributes and put the final class string back on it
        $attributes = $item->getAttributes();
        if (!empty($class)) {
            $attributes['class'] = implode(' ', $class);
        }

        return $attributes;
    }