app/library/Services.php: load menu config from file.
This commit is contained in:
parent
a8a448331e
commit
d2ef7f2c52
2 changed files with 30 additions and 34 deletions
27
app/config/menu.yml
Normal file
27
app/config/menu.yml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
menu:
|
||||||
|
home:
|
||||||
|
caption: Home
|
||||||
|
route: home-route
|
||||||
|
controller: index
|
||||||
|
action: index
|
||||||
|
create-new:
|
||||||
|
caption: 'Create new'
|
||||||
|
resource: callback
|
||||||
|
controller: callback
|
||||||
|
action: new
|
||||||
|
my-callbacks:
|
||||||
|
caption: 'List callbacks'
|
||||||
|
resource: callback
|
||||||
|
controller: callback
|
||||||
|
action: list
|
||||||
|
children:
|
||||||
|
show:
|
||||||
|
resource: callback
|
||||||
|
controller: callback
|
||||||
|
action: show
|
||||||
|
about:
|
||||||
|
caption: About
|
||||||
|
route: about-route
|
||||||
|
controller: index
|
||||||
|
action: about
|
||||||
|
|
@ -67,6 +67,7 @@ class Services extends DiDefault
|
||||||
$files = array(
|
$files = array(
|
||||||
'app.yml',
|
'app.yml',
|
||||||
'routes.yml',
|
'routes.yml',
|
||||||
|
'menu.yml',
|
||||||
'local.yml'
|
'local.yml'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -271,41 +272,9 @@ class Services extends DiDefault
|
||||||
*/
|
*/
|
||||||
protected function _initMenu()
|
protected function _initMenu()
|
||||||
{
|
{
|
||||||
$config = array(
|
$config = $this->get('config')->menu;
|
||||||
'home' => array(
|
|
||||||
'caption' => 'Home',
|
|
||||||
'route' => 'home-route',
|
|
||||||
'controller' => 'index',
|
|
||||||
'action' => 'index',
|
|
||||||
),
|
|
||||||
'create-new ' => array(
|
|
||||||
'caption' => 'Create new',
|
|
||||||
'resource' => 'callback',
|
|
||||||
'controller' => 'callback',
|
|
||||||
'action' => 'new',
|
|
||||||
),
|
|
||||||
'my-callbacks' => array(
|
|
||||||
'caption' => 'List callbacks',
|
|
||||||
'resource' => 'callback',
|
|
||||||
'controller' => 'callback',
|
|
||||||
'action' => 'list',
|
|
||||||
'children' => array(
|
|
||||||
'show' => array(
|
|
||||||
'resource' => 'callback',
|
|
||||||
'controller' => 'callback',
|
|
||||||
'action' => 'show',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'about' => array(
|
|
||||||
'route' => 'about-route',
|
|
||||||
'caption' => 'About',
|
|
||||||
'controller' => 'index',
|
|
||||||
'action' => 'about'
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$navigation = new Navigation($config);
|
$navigation = new Navigation($config->toArray());
|
||||||
|
|
||||||
$menu = new Menu($navigation);
|
$menu = new Menu($navigation);
|
||||||
$menu->setMenuClass(null);
|
$menu->setMenuClass(null);
|
||||||
|
|
|
||||||
Reference in a new issue