Separating sub navigation and top level navigation configuration in my module.config.php

Using zf2 I have a subnav bar that appears on every page of one of my modules. Its rendered with a view helper and a partial (all contained in the module). The module pulls the config from its own module.config.php:

'navigation' => array(
    'default' => array(
        array(
            'label' => 'aaa',
            'route' => 'aaa',
        ),
        array(
            'label' => 'bbb',
            'route' => 'bbb',
        ),
        array(
            'label' => 'ccc',
            'route' => 'ccc', ...

Now I want to add a configuration for my site wide navbar that is rendered in the application module. The problem of course is that the configs are merged so I can't just add a 'navigation' key in the application module's module.config.php.

What's the best when to handle this? How can I have my module specific subnavs and my top level nav stored and segregated in the service manager?

Answers


The problem of course is that the configs are merged

Why is that a problem?

Application (module.config.php)

'navigation' => array(
   'default' => array(
     // application pages...
   )
 ),

FooModule (module.config)

'navigation' = array(
  'foo_nav' => array(
     // foo pages...
   ),
   'foo_module_specific_sidebar_name' = array(
     // foo sidebar pages
   )
),

Merged config

'navigation' => array(
   'default' => array(
     // application pages...
   ),
  'foo_nav' => array(
     // foo pages...
   ),
   'foo_module_specific_sidebar_name' = array(
     // foo sidebar pages
   )
),

ZF2 merges using array_merge_recursive()

If the input arrays have the same string keys, then the values for these keys are merged together into an array, and this is done recursively, so that if one of the values is an array itself, the function will merge it with a corresponding entry in another array too

Providing you you are not duplicating the navigation names and have the appropriate factories where you place the config doesn't really matter.


Need Your Help

"rect" class can't be the parameterof the method "screen.blit()"

python python-2.7 pygame

I want to draw a rectangle to be a simplified rocket, but my pycharm shows argument 1 must be pygame.Surface, not pygame.Rect just like in the picture.

$routeProvider not showing view

angularjs

I have the following .config()