Example #1
0
 /**
  * Responsible for adding attributes to menu item groups
  *
  * @param string        $type see switch for details
  * @param ItemInterface $menu
  */
 public function setMenuAttributes($type, ItemInterface $menu)
 {
     if (isset($this->getBag()->get('config')->nav->attributes->{$type})) {
         $attributes = (array) $this->getBag()->get('config')->nav->attributes->{$type};
         switch ($type) {
             case 'root':
                 // set attribs on top ul
                 $menu->setChildrenAttributes($attributes);
                 break;
             case 'parent':
                 // set attribs on sub uls
                 $menu->setChildrenAttributes($attributes);
                 break;
             case 'child':
                 // set attribs on li
                 $menu->setAttributes($attributes);
                 break;
             case 'link':
                 // set attribs on a tags
                 $menu->setLinkAttributes($attributes);
                 break;
             case 'label':
                 // set attribs on span tags
                 $menu->setLabelAttributes($attributes);
                 break;
             default:
                 break;
         }
     }
 }