Skip to content

Instantly share code, notes, and snippets.

@webs86
Created March 7, 2016 16:25
Show Gist options
  • Save webs86/dd0bc06c757b6044cee0 to your computer and use it in GitHub Desktop.
Save webs86/dd0bc06c757b6044cee0 to your computer and use it in GitHub Desktop.
<?php
namespace My\CustomBundle;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAware;
class FixtureMenu extends ContainerAware implements FixtureInterface
{
public function load(ObjectManager $objectManager)
{
$factory = $this->container->get('ktw_database_menu.factory');
$menu = $factory->createItem('root');
$menu->setChildrenAttribute('class', 'main-nav nav navbar-nav');
$menu->addChild('Home', array('route' => 'homepage'));
$menu->addChild('Page 1', array('route' => 'page1'));
$menu->addChild('Page 2', array('route' => 'page2'));
$objectManager->persist($menu);
$objectManager->flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment