Beispiel #1
0
	public function load($manager)
	{
		$menuCnt = 0;
		for($p = 0; $p < 10; $p++)
		{
			$page = new Entity\Page();
			$page->setTitle("lôrém page #{$p}");
			$page->setContent("lorem page ipsum #{$p}");

			$manager->persist($page);	
			
			if(round(mt_rand(0, 1)) && $menuCnt < 3)
			{
				$item = new Entity\MenuItem();
				$item->setTitle($page->getTitle());
				$item->setRouting('page');
				$item->setArguments(array('slug' => $page->getSlug()));
				$item->setIdentifier($page->getMenuIdentifier());
	
				$manager->getRepository('GoGreat\CMSBaseBundle\Entity\MenuItem')->persist($item);
				$menuCnt++;
			}
					
		}

		$manager->flush();
	}
	/**
	 * remove an instance of Page with the entity_manager
	 * 
	 * @param Page $page
	 */
	public function remove(Page $page)
	{		
		$em = $this->getEntityManager();
		
		$menu_item = $em->getRepository('GoGreat\CMSBaseBundle\Entity\MenuItem')
						->findOneByIdentifier($page->getMenuIdentifier());
				
		if($menu_item)
			$em->remove($menu_item);
		
		$em->remove($page);
	}