I'm using symfony and yaml to configure something like this:
foo_menu:
groups:
main:
items:
# ...
side:
items:
# ...
footer:
items:
# ...
My idea was that each tree defined under foo_menu.groups
should have an own service definition. Each service is in instance of a MenuService
and has all defined items in it. Each service should be accesable by name, e.g. foo.menu.main
, foo.menu.side
, ...
The menu building works perfectly, but I don't know how and where to register the service names.
I tried to use a compiler pass, but it won't work:
final class MenuCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
// ...
foreach ($names as $name) {
$id = sprintf('foo.menu.group.%s', $name);
$menu = $factory->getMenu($name);
$container->set($id, $menu);
}
}
}