public function load(ObjectManager $em)
 {
     $places = ['maison', 'bicoque', 'bidonville', 'lupanard', 'chateau', 'manoir', 'villa', 'residence'];
     $zones = ['10' => 'chambre', '11' => 'cuisine', '12' => 'séjour', '13' => 'couloir', '14' => 'salle_de_bain'];
     foreach ($places as $placeName) {
         foreach ($zones as $ip => $zoneName) {
             $radia1 = new Node();
             $radia1->setZone($em->merge($this->getReference('zone-' . $placeName . '-' . $zoneName)));
             $radia1->setName('Radiateur 1');
             $radia1->setIp('192.168.' . $ip . '.1');
             $radia2 = new Node();
             $radia2->setZone($em->merge($this->getReference('zone-' . $placeName . '-' . $zoneName)));
             $radia2->setName('Radiateur 2');
             $radia2->setIp('192.168.' . $ip . '.2');
             $lum1 = new Node();
             $lum1->setZone($em->merge($this->getReference('zone-' . $placeName . '-' . $zoneName)));
             $lum1->setName('Lumière 1');
             $lum1->setIp('192.168.' . $ip . '.3');
             $lum2 = new Node();
             $lum2->setZone($em->merge($this->getReference('zone-' . $placeName . '-' . $zoneName)));
             $lum2->setName('Lumière 2');
             $lum2->setIp('192.168.' . $ip . '.4');
             $stor1 = new Node();
             $stor1->setZone($em->merge($this->getReference('zone-' . $placeName . '-' . $zoneName)));
             $stor1->setName('Volet 1');
             $stor1->setIp('192.168.' . $ip . '.5');
             $stor2 = new Node();
             $stor2->setZone($em->merge($this->getReference('zone-' . $placeName . '-' . $zoneName)));
             $stor2->setName('Volet 2');
             $stor2->setIp('192.168.' . $ip . '.6');
             $stor3 = new Node();
             $stor3->setZone($em->merge($this->getReference('zone-' . $placeName . '-' . $zoneName)));
             $stor3->setName('Volet 3');
             $stor3->setIp('192.168.' . $ip . '.7');
             $em->persist($radia1);
             $em->persist($radia2);
             $em->persist($lum1);
             $em->persist($lum2);
             $em->persist($stor1);
             $em->persist($stor2);
             $em->persist($stor3);
             $this->addReference('node-rad1-' . $placeName . '-' . $zoneName, $radia1);
             $this->addReference('node-rad2-' . $placeName . '-' . $zoneName, $radia2);
             $this->addReference('node-lum1-' . $placeName . '-' . $zoneName, $lum1);
             $this->addReference('node-lum2-' . $placeName . '-' . $zoneName, $lum2);
             $this->addReference('node-stor1-' . $placeName . '-' . $zoneName, $stor1);
             $this->addReference('node-stor2-' . $placeName . '-' . $zoneName, $stor2);
             $this->addReference('node-stor3-' . $placeName . '-' . $zoneName, $stor3);
         }
     }
     $em->flush();
 }
 /**
  * Creates a new Node entity.
  *
  */
 public function createAction(Request $request, $idPlace, $idZone)
 {
     $em = $this->getDoctrine()->getManager();
     $zone = $em->getRepository('JarryUbuBundle:Zone')->findOneById($idZone);
     $entity = new Node();
     $entity->setZone($zone);
     $form = $this->createCreateForm($entity, $idPlace, $idZone);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('node_show', array('id' => $entity->getId(), 'idPlace' => $idPlace, 'idZone' => $idZone)));
     }
     return $this->render('JarryUbuBundle:Node:new.html.twig', array('entity' => $entity, 'idPlace' => $idPlace, 'idZone' => $idZone, 'form' => $form->createView()));
 }