/**
  * @Route("/installer/step/2")
  * @Template()
  */
 public function locationAction()
 {
     $em = $this->getDoctrine()->getEntityManager();
     $location_step = new \Club\InstallerBundle\Step\LocationStep();
     $form = $this->createForm(new \Club\InstallerBundle\Form\LocationStep(), $location_step);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bindRequest($this->getRequest());
         if ($form->isValid()) {
             $location = new \Club\UserBundle\Entity\Location();
             $location->setLocation($em->find('ClubUserBundle:Location', 1));
             $location->setLocationName($location_step->location_name);
             $em->persist($location);
             $location_config = $em->getRepository('ClubUserBundle:LocationConfig')->findOneBy(array('location' => 1, 'config' => 'default_currency'));
             $location_config->setValue($location_step->currency->getId());
             $em->persist($location_config);
             $em->flush();
             $this->get('session')->set('installer_location_id', $location->getId());
             return $this->redirect($this->generateUrl('club_installer_installer_confirm'));
         }
     }
     return array('form' => $form->createView());
 }
 /**
  * @Route("/step/3")
  * @Template()
  */
 public function locationAction()
 {
     $this->validateInstaller();
     $em = $this->getDoctrine()->getManager();
     $location_step = new \Club\InstallerBundle\Step\LocationStep();
     $form = $this->createForm(new \Club\InstallerBundle\Form\LocationStep(), $location_step);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bind($this->getRequest());
         if ($form->isValid()) {
             $location = new \Club\UserBundle\Entity\Location();
             $location->setLocationName($location_step->location_name);
             $location->setClub(true);
             $em->persist($location);
             $lc = new \Club\UserBundle\Entity\LocationConfig();
             $lc->setConfig('default_currency');
             $lc->setLocation($location);
             $lc->setValue($location_step->currency->getId());
             $em->persist($lc);
             $lc = new \Club\UserBundle\Entity\LocationConfig();
             $lc->setConfig('email_sender_address');
             $lc->setLocation($location);
             $lc->setValue('*****@*****.**');
             $em->persist($lc);
             $lc = new \Club\UserBundle\Entity\LocationConfig();
             $lc->setConfig('email_sender_name');
             $lc->setLocation($location);
             $lc->setValue('ClubMaster Administrator');
             $em->persist($lc);
             $em->flush();
             $this->get('session')->set('installer_location_id', $location->getId());
             return $this->redirect($this->generateUrl('club_installer_installer_confirm'));
         }
     }
     return array('form' => $form->createView());
 }
 public function load($manager)
 {
     $location = new \Club\UserBundle\Entity\Location();
     $location->setLocationName('ClubMaster');
     $manager->persist($location);
     $config = $this->getReference('config_account_default_cash');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue(1);
     $manager->persist($lc);
     $config = $this->getReference('config_account_default_income');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue(3);
     $manager->persist($lc);
     $config = $this->getReference('config_account_default_vat');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue(2);
     $manager->persist($lc);
     $config = $this->getReference('config_account_default_discount');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue(4);
     $manager->persist($lc);
     $config = $this->getReference('config_default_language');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue(1);
     $manager->persist($lc);
     $config = $this->getReference('config_default_currency');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue(1);
     $manager->persist($lc);
     $config = $this->getReference('config_default_location');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue(2);
     $manager->persist($lc);
     $config = $this->getReference('config_email_sender_address');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue('*****@*****.**');
     $manager->persist($lc);
     $config = $this->getReference('config_email_sender_name');
     $lc = new \Club\UserBundle\Entity\LocationConfig();
     $lc->setLocation($location);
     $lc->setConfig($config->getConfigKey());
     $lc->setValue('ClubMaster');
     $manager->persist($lc);
     $manager->flush();
 }