Skip to content

Commit

Permalink
allow to create a new menu via 'make' method
Browse files Browse the repository at this point in the history
  • Loading branch information
Gravitano committed Jun 29, 2015
1 parent d29d2b5 commit 2f82ebd
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Pingpong/Menus/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@ public function __construct(Factory $views, Repository $config)
* Make new menu.
*
* @param string $name
* @param Closure $callback
*
* @return \Pingpong\Menus\MenuBuilder
*/
public function make($name)
public function make($name, \Closure $callback)
{
$builder = new MenuBuilder($name, $this->config);

$builder->setViewFactory($this->views);

$this->menus[$name] = $builder;

return $builder;
return $this->create($name, $callback);
}

/**
Expand All @@ -56,9 +51,13 @@ public function make($name)
*/
public function create($name, Closure $resolver)
{
$menus = $this->make($name);
$builder = new MenuBuilder($name, $this->config);

$builder->setViewFactory($this->views);

$this->menus[$name] = $builder;

return $resolver($menus);
return $resolver($builder);
}

/**
Expand Down

0 comments on commit 2f82ebd

Please sign in to comment.