/** * Create new menu. * * @param string $name * @param Callable $resolver * * @return \Pingpong\Menus\MenuBuilder */ public function create($name, Closure $resolver) { $builder = new MenuBuilder($name, $this->config); $builder->setViewFactory($this->views); $this->menus[$name] = $builder; return $resolver($builder); }
/** * Make new menu. * * @param string $name * * @return \Pingpong\Menus\MenuBuilder */ public function make($name) { $builder = new MenuBuilder($name, $this->config); $builder->setViewFactory($this->views); $this->menus[$name] = $builder; return $builder; }
public function testCreateMenuFromBuilder() { $builder = new Builder('top', $this->config); $home = $builder->add(['title' => 'Home', 'url' => '/', 'icon' => 'fa fa-dashboard']); $settings = $builder->add(['title' => 'Settings', 'url' => '/settings', 'icon' => 'fa fa-tools']); $this->assertInstanceOf('Pingpong\\Menus\\MenuItem', $home); $this->assertEquals($builder->count(), 2); }
/** * Add children to menu under the give name * * @param string $name * @param object $children * @param Builder|MenuItem $menu */ private function addChildrenToMenu($name, $children, $menu, $attribs = []) { $menu->dropdown($name, function (PingpongMenuItem $subMenu) use($children) { foreach ($children as $child) { $this->addSubItemToMenu($child, $subMenu); } }, 0, $attribs); }