/**
  * @return a Navigation instance with the specified information
  */
 protected function createMenuNode(DocumentManager $dm, $parent, $name, $label, $content, $uri = null, $route = null)
 {
     if (!$parent instanceof MenuNode && !$parent instanceof Menu) {
         $menuNode = new Menu();
     } else {
         $menuNode = new MenuNode();
     }
     $menuNode->setParent($parent);
     $menuNode->setName($name);
     $dm->persist($menuNode);
     // do persist before binding translation
     if (null !== $content) {
         $menuNode->setContent($content);
     } else {
         if (null !== $uri) {
             $menuNode->setUri($uri);
         } else {
             if (null !== $route) {
                 $menuNode->setRoute($route);
             }
         }
     }
     if (is_array($label)) {
         foreach ($label as $locale => $l) {
             $menuNode->setLabel($l);
             $dm->bindTranslation($menuNode, $locale);
         }
     } else {
         $menuNode->setLabel($label);
     }
     return $menuNode;
 }
 /**
  * Load data fixtures with the passed DocumentManager
  *
  * @param DocumentManager $manager
  */
 public function load(ObjectManager $manager)
 {
     if (!$manager instanceof DocumentManager) {
         $class = get_class($manager);
         throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '{$class}' given.");
     }
     // tweak homepage
     $page = $manager->find(null, '/cms/simple');
     $page->setBody('Hello');
     $page->setDefault('_template', 'AcmeDemoBundle::home.html.twig');
     // add menu item for home
     $menuRoot = $manager->find(null, '/cms/simple');
     $homeMenuNode = new MenuNode('home');
     $homeMenuNode->setLabel('Home');
     $homeMenuNode->setParentDocument($menuRoot);
     $homeMenuNode->setContent($page);
     $manager->persist($homeMenuNode);
     // load the pages
     Fixtures::load(array(__DIR__ . '/../../Resources/data/pages.yml'), $manager);
     // add menu item for login
     $loginMenuNode = new MenuNode('login');
     $loginMenuNode->setLabel('Admin Login');
     $loginMenuNode->setParentDocument($menuRoot);
     $loginMenuNode->setRoute('_demo_login');
     $manager->persist($loginMenuNode);
     // load the blocks
     NodeHelper::createPath($manager->getPhpcrSession(), '/cms/content/blocks');
     Fixtures::load(array(__DIR__ . '/../../Resources/data/blocks.yml'), $manager);
     // save the changes
     $manager->flush();
 }
Esempio n. 3
0
 public function testMenuNode()
 {
     $data = array('name' => 'test-node', 'label' => 'label_foobar', 'uri' => 'http://www.example.com/foo', 'route' => 'foo_route', 'linkType' => 'route', 'content' => $this->content, 'publishable' => false, 'publishStartDate' => new \DateTime('2013-06-18'), 'publishEndDate' => new \DateTime('2013-06-18'), 'attributes' => array('attr_foobar_1' => 'barfoo', 'attr_foobar_2' => 'barfoo'), 'childrenAttributes' => array('child_foobar_1' => 'barfoo', 'child_foobar_2' => 'barfoo'), 'linkAttributes' => array('link_foobar_1' => 'barfoo', 'link_foobar_2' => 'barfoo'), 'labelAttributes' => array('label_foobar_1' => 'barfoo', 'label_foobar_2' => 'barfoo'), 'extras' => array('extra_foobar_1' => 'barfoo', 'extra_foobar_2' => 'barfoo'), 'routeParameters' => array('route_param_foobar_1' => 'barfoo', 'route_param_foobar_2' => 'barfoo'), 'routeAbsolute' => true, 'display' => false, 'displayChildren' => false);
     $startDateString = $data['publishStartDate']->format('Y-m-d');
     $endDateString = $data['publishEndDate']->format('Y-m-d');
     $menuNode = new MenuNode();
     $refl = new \ReflectionClass($menuNode);
     $menuNode->setParentDocument($this->rootDocument);
     foreach ($data as $key => $value) {
         $refl = new \ReflectionClass($menuNode);
         $prop = $refl->getProperty($key);
         $prop->setAccessible(true);
         $prop->setValue($menuNode, $value);
     }
     $menuNode->addChild($this->child1);
     $this->dm->persist($menuNode);
     $this->dm->flush();
     $this->dm->clear();
     $menuNode = $this->dm->find(null, '/test/test-node');
     $this->assertNotNull($menuNode);
     foreach ($data as $key => $value) {
         $prop = $refl->getProperty($key);
         $prop->setAccessible(true);
         $v = $prop->getValue($menuNode);
         if (!is_object($value)) {
             $this->assertEquals($value, $v);
         }
     }
     // test objects
     $prop = $refl->getProperty('content');
     $prop->setAccessible(true);
     $content = $prop->getValue($menuNode);
     $this->assertEquals('fake_weak_content', $content->getName());
     // test children
     $this->assertCount(1, $menuNode->getChildren());
     // test publish start and end
     $publishStartDate = $menuNode->getPublishStartDate();
     $publishEndDate = $menuNode->getPublishEndDate();
     $this->assertInstanceOf('\\DateTime', $publishStartDate);
     $this->assertInstanceOf('\\DateTime', $publishEndDate);
     $this->assertEquals($startDateString, $publishStartDate->format('Y-m-d'));
     $this->assertEquals($endDateString, $publishEndDate->format('Y-m-d'));
     // test multi-lang
     $menuNode->setLocale('fr');
     $this->dm->persist($menuNode);
     $this->dm->flush();
     $this->dm->clear();
     $menuNode = $this->dm->findTranslation(null, '/test/test-node', 'fr');
     $this->assertEquals('fr', $menuNode->getLocale());
     $child = $this->dm->find(null, '/test/test-node/child1');
     $menuNode = $child->getParent();
     $this->assertCount(1, $menuNode->getChildren());
     $menuNode->removeChild($child);
     $this->dm->flush();
     $this->dm->clear();
     $menuNode = $this->dm->find(null, '/test/test-node');
     $this->assertCount(0, $menuNode->getChildren());
 }
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager|DocumentManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $contentParent = $manager->find(null, '/cms/content');
     $routeParent = $manager->find(null, '/cms/routes');
     $menuBase = $manager->find(null, '/cms/menu');
     $enRoute = new Route();
     $enRoute->setPosition($routeParent, 'en');
     $manager->persist($enRoute);
     $deRoute = new Route();
     $deRoute->setPosition($routeParent, 'de');
     $manager->persist($deRoute);
     $enServiceRoute = new Route();
     $enServiceRoute->setPosition($enRoute, 'services');
     $manager->persist($enServiceRoute);
     $deServiceRoute = new Route();
     $deServiceRoute->setPosition($deRoute, 'dienstleistungen');
     $manager->persist($deServiceRoute);
     $content = new StaticContent();
     $content->setParentDocument($contentParent);
     $content->setName('symfony-service');
     $manager->persist($content);
     $content->setTitle('Symfony Service');
     $content->setBody('A page about Symfony service');
     $manager->bindTranslation($content, 'en');
     $contentRoute = new Route();
     $contentRoute->setPosition($enServiceRoute, 'symfony-service');
     $contentRoute->setContent($content);
     $manager->persist($contentRoute);
     $content->setTitle('Symfony Dienstleistungen');
     $content->setBody('Eine Seite über Symfony Dienstleistungen');
     $manager->bindTranslation($content, 'de');
     $contentRoute = new Route();
     $contentRoute->setPosition($deServiceRoute, 'symfony-dienstleistungen');
     $contentRoute->setContent($content);
     $manager->persist($contentRoute);
     $menu = new Menu();
     $menu->setPosition($menuBase, 'footer');
     $manager->persist($menu);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setContent($content);
     $menuNode->setName('symfony-service');
     $manager->persist($menuNode);
     $menuNode->setLabel('Symfony Services');
     $manager->bindTranslation($menuNode, 'en');
     $menuNode->setLabel('Symfony Dienstleistungen');
     $manager->bindTranslation($menuNode, 'de');
     $manager->flush();
 }
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager|DocumentManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $contentParent = $manager->find(null, '/cms/content');
     $routeParent = $manager->find(null, '/cms/routes/en/services');
     $menuBase = $manager->find(null, '/cms/menu/footer');
     $content = new DemoSeoContent();
     $content->setParentDocument($contentParent);
     $content->setName('seo-service');
     $content->setTitle('SEO Service');
     $content->setBody('A page about SEO service');
     $metaData = new SeoMetadata();
     $metaData->setMetaDescription('Description in Metadata');
     $content->setSeoMetadata($metaData);
     $manager->persist($content);
     $manager->bindTranslation($content, 'en');
     $contentRoute = new Route();
     $contentRoute->setParentDocument($routeParent);
     $contentRoute->setName('seo-service');
     $contentRoute->setContent($content);
     $manager->persist($contentRoute);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menuBase);
     $menuNode->setName('seo-service');
     $menuNode->setLabel('SEO Services');
     $menuNode->setContent($content);
     $manager->persist($menuNode);
     $manager->flush();
 }
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager|DocumentManager $manager
  */
 public function load(ObjectManager $manager)
 {
     if (!$manager instanceof DocumentManager) {
         $class = get_class($manager);
         throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '{$class}' given.");
     }
     // tweak homepage
     $page = $manager->find(null, '/cms/simple');
     $page->setBody('Hello');
     $page->setDefault('_template', 'IPCApplicationBundle::home.html.twig');
     // add menu item for home
     $menuRoot = $manager->find(null, '/cms/simple');
     $homeMenuNode = new MenuNode('home');
     $homeMenuNode->setLabel('Home');
     $homeMenuNode->setParentDocument($menuRoot);
     $homeMenuNode->setContent($page);
     $manager->persist($homeMenuNode);
     // load the pages
     Fixtures::load(array(__DIR__ . '/../../Resources/data/pages.yml'), $manager);
     // save the changes
     $manager->flush();
 }
 /**
  * Creates pages and their corresponding routes & menu entries
  * @param  ObjectManager $this->documentManager PHPCR ODM DocumentManager instance
  */
 private function createLondaPages()
 {
     //the menus
     $mainMenu = $this->createMenus();
     $pages = Yaml::parse(file_get_contents(__DIR__ . '/../../Resources/data/pages.yml'));
     //Create the pages and their corresponding routes and menu nodes
     foreach ($pages["KanzuCode\\LondaBundle\\Document\\Page"] as $pageId => $page) {
         //Define the route
         $route = new Route();
         $route->setParentDocument($this->documentManager->find(null, $this->config['parameters']['londa.basepath.routes']));
         $route->setName($page['route']);
         if (isset($page['template'])) {
             $route->setDefault('_template', "KanzuCodeLondaBundle:Default:{$page['template']}.html.twig");
         }
         if (isset($page['controller'])) {
             $route->setDefault('_controller', "KanzuCodeLondaBundle:LondaContent:{$page['controller']}");
         }
         $this->documentManager->persist($route);
         // add the route
         //Add menu node
         $menuNode = new MenuNode();
         $menuNode->setName($pageId);
         $menuNode->setLabel($page['title']);
         $menuNode->setParentDocument($mainMenu);
         $this->documentManager->persist($menuNode);
         //Do the content
         $content = new Page();
         $content->setParentDocument($this->documentManager->find(null, $this->config['parameters']['londa.basepath.pages']));
         $content->setName($pageId);
         $content->setTitle($page['title']);
         $content->setBody($page['body']);
         $content->addRoute($route);
         $content->addMenuNode($menuNode);
         $this->documentManager->persist($content);
     }
 }
Esempio n. 8
0
 /**
  * @param \Acme\BasicCmsBundle\Document\Page $document
  * @return void
  */
 public function postUpdate($document)
 {
     $nodeMenu = $this->getModelManager()->find(null, $document->getId());
     if (null === $nodeMenu) {
         $menu = $this->getModelManager()->find('Symfony\\Cmf\\Bundle\\MenuBundle\\Doctrine\\Phpcr\\Menu', '/cms/menu/main-menu');
         $nodeMenu = new MenuNode();
         $nodeMenu->setName($document->getSlug());
         $nodeMenu->setLabel($document->getTitle());
         $nodeMenu->setContent($document);
         $nodeMenu->setParentDocument($menu);
         /** @var DocumentManager $documentManager */
         $documentManager = $this->container->get('doctrine_phpcr')->getManager();
         $documentManager->persist($nodeMenu);
         $documentManager->flush();
     }
 }
 public function load(ObjectManager $manager)
 {
     $dataDir = __DIR__ . '/../../Resources/data';
     $session = $manager->getPhpcrSession();
     $yaml = new Parser();
     $basepath = $this->container->getParameter('cmf_simple_cms.persistence.phpcr.basepath');
     NodeHelper::createPath($session, preg_replace('#/[^/]*$#', '', $basepath));
     $data = $yaml->parse(file_get_contents($dataDir . '/page.yml'));
     foreach ($data['static'] as $overview) {
         $this->loadPage($manager, $basepath, $overview);
     }
     // load single pages
     $finder = new Finder();
     $finder->files()->name('*.yml')->in($dataDir . '/posts')->sortByName();
     foreach ($finder as $pageFile) {
         $post = array_merge(array('parent' => '/news', 'label' => false, 'format' => 'markdown', 'template' => 'cms/news_detail.html.twig'), $yaml->parse(file_get_contents($pageFile)));
         $this->loadPage($manager, $basepath, $post);
     }
     $data = $yaml->parse(file_get_contents(__DIR__ . '/../../Resources/data/external.yml'));
     $basepath = $this->container->getParameter('cmf_core.persistence.phpcr.basepath');
     $home = $manager->find(null, $basepath);
     foreach ($data['static'] as $name => $overview) {
         $item = new MenuNode();
         $item->setName($name);
         $item->setLabel($overview['label']);
         $item->setUri($overview['uri']);
         $item->setParentDocument($home);
         $manager->persist($item);
     }
     $blocks = $yaml->parse(file_get_contents(__DIR__ . '/../../Resources/data/block.yml'));
     $blockBasepath = $this->container->getParameter('cmf_block.persistence.phpcr.block_basepath');
     NodeHelper::createPath($session, $blockBasepath);
     $blocksHome = $manager->find(null, $blockBasepath);
     foreach ($blocks['static'] as $name => $block) {
         $this->loadBlock($manager, $blocksHome, $name, $block);
     }
     $manager->flush();
 }
 public function load(ObjectManager $dm)
 {
     $this->yaml = new Parser();
     parent::load($dm);
     $data = $this->yaml->parse(file_get_contents(__DIR__ . '/../../Resources/data/external.yml'));
     $basepath = $this->getBasePath();
     $home = $dm->find(null, $basepath);
     $route = new MultilangRoute();
     $route->setPosition($home, 'dynamic');
     $route->setDefault('_controller', 'AcmeMainBundle:Demo:dynamic');
     $dm->persist($route);
     foreach ($data['static'] as $name => $overview) {
         $menuItem = new MenuNode();
         $menuItem->setName($name);
         $menuItem->setParent($home);
         if (!empty($overview['route'])) {
             if (!empty($overview['uri'])) {
                 $route = new MultilangRedirectRoute();
                 $route->setPosition($home, $overview['route']);
                 $route->setUri($overview['uri']);
                 $dm->persist($route);
             } else {
                 $route = $dm->find(null, $basepath . '/' . $overview['route']);
             }
             $menuItem->setRoute($route->getId());
         } else {
             $menuItem->setUri($overview['uri']);
         }
         $dm->persist($menuItem);
         foreach ($overview['label'] as $locale => $label) {
             $menuItem->setLabel($label);
             if ($locale) {
                 $dm->bindTranslation($menuItem, $locale);
             }
         }
     }
     $dm->flush();
 }
Esempio n. 11
0
 public function testMultilang()
 {
     $n = new MenuNode();
     $n->setLocale('fr');
     $this->assertEquals('fr', $n->getLocale());
 }
Esempio n. 12
0
 protected function loadVoterMenu(DocumentManager $manager)
 {
     // test content
     $content = new Content();
     $content->setTitle('Content 1');
     $content->setId('/test/content-1');
     $manager->persist($content);
     $route = new Route();
     $route->setId('/test/routes/contents/content-1');
     $route->setDefault('_controller', 'Symfony\\Cmf\\Bundle\\MenuBundle\\Tests\\Resources\\Controller\\VoterController::requestContentIdentityAction');
     $route->setContent($content);
     $manager->persist($route);
     // test blog
     $blog = new Content();
     $blog->setTitle('Blog');
     $blog->setId('/test/blog-1');
     $manager->persist($blog);
     $route = new Route();
     $route->setId('/test/routes/blog');
     $route->setDefault('_controller', 'Symfony\\Cmf\\Bundle\\MenuBundle\\Tests\\Resources\\Controller\\VoterController::blogAction');
     $route->setContent($blog);
     $manager->persist($route);
     // test blog post
     $post = new Post();
     $post->setTitle('My Post');
     $post->setId('/test/blog-1/my-post');
     $manager->persist($post);
     $route = new Route();
     $route->setId('/test/routes/blog/my-post');
     $route->setDefault('_controller', 'Symfony\\Cmf\\Bundle\\MenuBundle\\Tests\\Resources\\Controller\\VoterController::postAction');
     $route->setContent($post);
     $manager->persist($route);
     // test articles
     $articles = new Content();
     $articles->setTitle('Articles Index');
     $articles->setId('/test/articles');
     $manager->persist($articles);
     $articlesRoute = new Route();
     $articlesRoute->setId('/test/routes/articles');
     $articlesRoute->setDefault('_controller', 'Symfony\\Cmf\\Bundle\\MenuBundle\\Tests\\Resources\\Controller\\VoterController::articlesAction');
     $articlesRoute->setContent($articles);
     $articlesRoute->setOption('currentUriPrefix', '/articles');
     $manager->persist($articlesRoute);
     $article1 = new Content();
     $article1->setTitle('Article 1');
     $article1->setId('/test/article-1');
     $manager->persist($article1);
     $route = new Route();
     $route->setId('/test/routes/articles/some-category');
     $manager->persist($route);
     $route = new Route();
     $route->setId('/test/routes/articles/some-category/article-1');
     $route->setDefault('_controller', 'Symfony\\Cmf\\Bundle\\MenuBundle\\Tests\\Resources\\Controller\\VoterController::postAction');
     $route->setContent($article1);
     $manager->persist($route);
     // menu items
     $menu = new Menu();
     $menu->setName('side-menu');
     $menu->setLabel('Side Menu');
     $menu->setParentDocument($this->menuRoot);
     $manager->persist($menu);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('Default Behavior');
     $menuNode->setName('default');
     $menuNode->setRoute('current_menu_item_default');
     $manager->persist($menuNode);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('Request Content Identity Voter');
     $menuNode->setName('request-content-identity-voter');
     $menuNode->setContent($content);
     $manager->persist($menuNode);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('URI Prefix Voter');
     $menuNode->setName('uri-prefix-voter');
     $menuNode->setContent($articlesRoute);
     $manager->persist($menuNode);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('Request Parent Content Identity Voter');
     $menuNode->setName('request-parent-content-identity-voter');
     $menuNode->setContent($blog);
     $manager->persist($menuNode);
 }
Esempio n. 13
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $parent = new Generic();
     $parent->setParentDocument($root);
     $parent->setNodename('blocks');
     $manager->persist($parent);
     //Simple
     $block = new SimpleBlock();
     $block->setParentDocument($parent);
     $block->setName('block-1');
     $block->setTitle('block-1-title');
     $block->setBody('block-1-body');
     $manager->persist($block);
     $block = new SimpleBlock();
     $block->setParentDocument($parent);
     $block->setName('block-2');
     $block->setTitle('block-2-title');
     $block->setBody('block-2-body');
     $block->setPublishable(false);
     $manager->persist($block);
     //Action
     $actionBlockOne = new ActionBlock();
     $actionBlockOne->setParentDocument($parent);
     $actionBlockOne->setName('action-block-1');
     $actionBlockOne->setActionName('cmf_block_test.test_controller:dummyAction');
     $actionBlockOne->setPublishable(true);
     $manager->persist($actionBlockOne);
     $actionBlockTwo = new ActionBlock();
     $actionBlockTwo->setParentDocument($parent);
     $actionBlockTwo->setName('action-block-2');
     $actionBlockTwo->setActionName('FooBundle:Bar:actionTwo');
     $actionBlockTwo->setPublishable(false);
     $manager->persist($actionBlockTwo);
     //Container
     $childBlockOne = new SimpleBlock();
     $childBlockOne->setName('block-child-1');
     $childBlockOne->setTitle('block-child-1-title');
     $childBlockOne->setBody('block-child-1-body');
     $containerBlock = new ContainerBlock();
     $containerBlock->setParentDocument($parent);
     $containerBlock->setName('container-block-1');
     $containerBlock->addChild($childBlockOne);
     $manager->persist($containerBlock);
     $block = new ContainerBlock();
     $block->setParentDocument($parent);
     $block->setName('container-block-2');
     $block->setPublishable(false);
     $manager->persist($block);
     //Reference
     $block = new ReferenceBlock();
     $block->setParentDocument($parent);
     $block->setName('reference-block-1');
     $block->setReferencedBlock($actionBlockOne);
     $manager->persist($block);
     $block = new ReferenceBlock();
     $block->setParentDocument($parent);
     $block->setName('reference-block-2');
     $block->setReferencedBlock($actionBlockTwo);
     $block->setPublishable(false);
     $manager->persist($block);
     // Menu Nodes
     NodeHelper::createPath($manager->getPhpcrSession(), '/test/menus');
     $menuRoot = $manager->find(null, '/test/menus');
     $menu = new Menu();
     $menu->setName('test-menu');
     $menu->setLabel('Test Menu');
     $menu->setParentDocument($menuRoot);
     $manager->persist($menu);
     $menuNodeOne = new MenuNode();
     $menuNodeOne->setName('menu-node-1');
     $menuNodeOne->setLabel('menu-node-1');
     $menuNodeOne->setParentDocument($menu);
     $manager->persist($menuNodeOne);
     $menuNodeTwo = new MenuNode();
     $menuNodeTwo->setName('menu-node-2');
     $menuNodeTwo->setLabel('menu-node-2');
     $menuNodeTwo->setParentDocument($menu);
     $manager->persist($menuNodeTwo);
     //Menu
     $block = new MenuBlock();
     $block->setParentDocument($parent);
     $block->setName('menu-block-1');
     $block->setMenuNode($menuNodeOne);
     $manager->persist($block);
     $block = new MenuBlock();
     $block->setParentDocument($parent);
     $block->setName('menu-block-2');
     $block->setMenuNode($menuNodeTwo);
     $block->setPublishable(false);
     $manager->persist($block);
     //String
     $block = new StringBlock();
     $block->setParentDocument($parent);
     $block->setName('string-block-1');
     $block->setBody('string-block-1-body');
     $manager->persist($block);
     $block = new StringBlock();
     $block->setParentDocument($parent);
     $block->setName('string-block-2');
     $block->setBody('string-block-2-body');
     $block->setPublishable(false);
     $manager->persist($block);
     $manager->flush();
 }
Esempio n. 14
0
 protected function loadMenu(DocumentManager $manager)
 {
     $route = new Route();
     $route->setName('content-1');
     $route->setParentDocument($this->routeRoot);
     $manager->persist($route);
     $content = new Content();
     $content->setTitle('Menu Item Content 1');
     $content->setId('/test/content-menu-item-1');
     $content->addRoute($route);
     $menu = new Menu();
     $menu->setName('test-menu');
     $menu->setLabel('Test Menu');
     $menu->setParentDocument($this->menuRoot);
     $manager->persist($menu);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('item-1');
     $menuNode->setName('item-1');
     $manager->persist($menuNode);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('This node has a URI');
     $menuNode->setUri('http://www.example.com');
     $menuNode->setName('item-2');
     $manager->persist($menuNode);
     $subNode = new MenuNode();
     $subNode->setParentDocument($menuNode);
     $subNode->setLabel('This node has content');
     $subNode->setName('sub-item-1');
     $subNode->setContent($content);
     $manager->persist($subNode);
     $content->addMenuNode($subNode);
     $subNode = new MenuNode();
     $subNode->setParentDocument($menuNode);
     $subNode->setLabel('This node has an assigned route');
     $subNode->setName('sub-item-2');
     $subNode->setRoute('link_test_route');
     $manager->persist($subNode);
     $subNode = new MenuNode();
     $subNode->setParentDocument($menuNode);
     $subNode->setLabel('This node has an assigned route with parameters');
     $subNode->setName('sub-item-3');
     $subNode->setRoute('link_test_route_with_params');
     $subNode->setRouteParameters(array('foo' => 'bar', 'bar' => 'foo'));
     $manager->persist($subNode);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('item-3');
     $menuNode->setName('item-3');
     $manager->persist($menuNode);
     $menu = new Menu();
     $menu->setName('another-menu');
     $menu->setLabel('Another Menu');
     $menu->setParentDocument($this->menuRoot);
     $manager->persist($menu);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('This node has uri, route and content set. but linkType is set to route');
     $menuNode->setLinkType('route');
     $menuNode->setUri('http://www.example.com');
     $menuNode->setRoute('link_test_route');
     $menuNode->setName('item-1');
     $manager->persist($menuNode);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setLabel('item-2');
     $menuNode->setName('item-2');
     $manager->persist($menuNode);
     $manager->persist($content);
 }
 /**
  * Create a menu node (an item in a menu)
  * @param string $menuName The node name
  * @param string $menuLabel The node label
  * @param Menu   $mainMenu Menu to which the node should be added
  */
 private function createMainMenuNode($menuName, $menuLabel, $mainMenu)
 {
     $menuNode = new MenuNode();
     $menuNode->setName($menuName);
     $menuNode->setLabel($menuLabel);
     $menuNode->setParentDocument($mainMenu);
     return $menuNode;
 }