/**
  * Creates a new Site entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Site();
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $node = new Node();
         $node->setTitle($entity->getLibelle());
         $entity->setNode($node);
         $node->setBloquer(true);
         $nodeCategorie = new Node();
         $nodeCategorie->setTitle("Categories");
         $nodeCategorie->setParent($node);
         $nodeCategorie->setBloquer(true);
         $nodePlacements = new Node();
         $nodePlacements->setTitle("Placements");
         $nodePlacements->setParent($node);
         $nodePlacements->setBloquer(true);
         $nodeAdmin = new Node();
         $nodeAdmin->setTitle("Administration");
         $nodeAdmin->setParent($node);
         $nodeAdmin->setBloquer(true);
         $nodeMenuAdmin = new Node();
         $nodeMenuAdmin->setTitle("Menu administration");
         $nodeMenuAdmin->setParent($nodeAdmin);
         $nodeMenuAdmin->setBloquer(true);
         $nodeConfig = new Node();
         $nodeConfig->setTitle("Configuration");
         $nodeConfig->setParent($node);
         $nodeConfig->setBloquer(true);
         $em->persist($entity);
         $em->persist($node);
         $em->persist($nodeCategorie);
         $em->persist($nodePlacements);
         $em->persist($nodeAdmin);
         $em->persist($nodeMenuAdmin);
         $em->persist($nodeConfig);
         $em->flush();
         return $this->redirect($this->generateUrl('superadmin_multi_site'));
     }
     return $this->render('MultiSiteBundle:Site:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
 public function getSousCategories(\Id2i\Core\NodeBundle\Entity\Node $parent)
 {
     return $this->_em->createQueryBuilder()->select(array('n'))->from('NodeBundle:Node', 'n')->where('n.parent = :parent AND n.root = :root AND n.lft > :parentLft AND n.rgt < :parentRgt')->setParameters(array('parent' => $parent, 'root' => $parent->getRoot(), 'parentLft' => $parent->getLft(), 'parentRgt' => $parent->getRgt()));
 }
 public function newChildAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $entity = $em->getRepository('NodeBundle:Node')->find($id);
     $new = new Node();
     $new->setTitle("Nouvel élément");
     $new->setParent($entity);
     $em->persist($new);
     $em->flush();
     return $this->redirect($this->generateUrl('superadmin_node'));
 }