Beispiel #1
0
 /**
  * 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);
 }
Beispiel #2
0
 /**
  * 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;
 }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 /**
  * 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);
 }