Exemple #1
0
 /**
  * Handles the creation of a menu, or returns it if it exists
  *
  * @param  string       $menuName
  * @param  string 		$menuText
  * @param  array 		$attributes
  * @return Stillat\Menu
  */
 public function handle($menuName, $menuText, array $attributes = array())
 {
     if ($this->hasMenu($menuName) == false) {
         $attributes['text'] = $menuText;
         $menu = new Menu($menuName, $attributes);
         $menu->setRenderer($this->renderer);
         $this->menuCollection->put($menuName, $menu);
     }
     return $this->getMenu($menuName);
 }
Exemple #2
0
 /**
  * Takes an existing sub menu item and renders it
  * 
  * @param  \Stillat\Menu\MenuItem $menu
  * @param  array 				 $options 
  * @return string
  */
 protected function renderSubMenu(Menu $menu, array $options = array())
 {
     $menu->setAttribute('child', true);
     $menu->setAttribute('level', intval($options['level']) + 1);
     return $menu->render($options);
 }
Exemple #3
0
 /**
  * Adds a new sub menu before an existing menu.
  * 
  * @param  string $afterMenu 
  * @param  \Stillat\Menu\Menu $menu 
  * @return void
  */
 public function addMenuBefore($beforeMenu, $menu)
 {
     if (!$this->hasItem($beforeMenu)) {
         throw new InvalidArgumentException("The menu item '{$beforeMenu}' does not exist.");
     }
     $this->items->insertBefore($beforeMenu, array($menu->getName(), $menu));
 }