Skip to content

Instantly share code, notes, and snippets.

@janit
Created January 27, 2016 05:32
Show Gist options
  • Save janit/18c26efb9c9d807ed655 to your computer and use it in GitHub Desktop.
Save janit/18c26efb9c9d807ed655 to your computer and use it in GitHub Desktop.
<?php
$factory = $this->container->get('ktw_database_menu.factory');
$menu = $factory->createItem('root');
$menu->addChild('Home', array('route' => 'homepage'));
$menu->addChild('About Me', array(
'route' => 'page_show',
'routeParameters' => array('id' => 42)));
// Another way to add children ...
$parentMenuItem = $factory->createItem('Parent', array('route' => 'parent_route'));
$parentMenuItem->addChild('Grandchild', array('route' => 'grandchild_route'));
$menu->addChild($parentMenuItem);
$objectManager->persist($menu);
$objectManager->flush();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment