/**
  * Displays a form to edit an existing locale entity or create a new one.
  *
  * @param integer $id      The id of the Locale to edit
  * @param Request $request
  *
  * @return RedirectResponse|Response
  */
 public function editAction($id, Request $request)
 {
     /**
      * @var $locale Locale
      */
     $locale = $this->getEm()->getRepository('UnifikSystemBundle:Locale')->find($id);
     if (false == $locale) {
         $locale = new Locale();
         $locale->setContainer($this->container);
     }
     $this->pushNavigationElement($locale);
     $form = $this->createForm(new LocaleType(), $locale);
     if ('POST' == $request->getMethod()) {
         $form->submit($request);
         if ($form->isValid()) {
             $this->getEm()->persist($locale);
             $this->getEm()->flush();
             $this->addFlashSuccess($this->get('translator')->trans('%entity% has been saved.', array('%entity%' => $locale)));
             $this->invalidateDatabaseConfig();
             if ($request->request->has('save')) {
                 return $this->redirect($this->generateUrl('unifik_system_backend_locale'));
             }
             return $this->redirect($this->generateUrl($locale->getRoute(), $locale->getRouteParams()));
         } else {
             $this->addFlashError('Some fields are invalid.');
         }
     }
     return $this->render('UnifikSystemBundle:Backend/Locale/Locale:edit.html.twig', array('locale' => $locale, 'default_locale' => $this->container->getParameter('locale'), 'form' => $form->createView()));
 }
 /**
  * Load
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $metadata = $manager->getClassMetaData('Unifik\\SystemBundle\\Entity\\Locale');
     $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
     $localeFr = new Locale();
     $localeFr->setId(1);
     $localeFr->setName('Français');
     $localeFr->setCode('fr');
     $localeFr->setActive(true);
     $manager->persist($localeFr);
     $localeEn = new Locale();
     $localeEn->setId(2);
     $localeEn->setName('English');
     $localeEn->setCode('en');
     $localeEn->setActive(true);
     $manager->persist($localeEn);
     $manager->flush();
     $this->addReference('locale-fr', $localeFr);
     $this->addReference('locale-en', $localeEn);
 }