Symfony\Component\HttpFoundation\Request::setLocale PHP Method

setLocale() public method

Sets the locale.
public setLocale ( string $locale )
$locale string
    public function setLocale($locale)
    {
        $this->setPhpDefaultLocale($this->locale = $locale);
    }

Usage Example

Example #1
0
 /**
  * Lists all Scheda entities.
  *
  * @Route("//{page}/{lang}", name="scheda", options={"expose": true}, defaults={"page" = 0, "lang" = "it"})
  * @Method("GET")
  * @Template()
  * 
  */
 public function indexAction(Request $request, $page, $lang)
 {
     $data = null;
     $esito = null;
     # $session = new Session();
     $session = $request->getSession();
     $session->start();
     if ($lang == "en") {
         $request->setLocale("en_EN");
         $session->set("lang", "en");
     } else {
         $request->setLocale("it_IT");
         $session->set("lang", "it");
     }
     if ($session->has("esito")) {
         $esito = $session->getFlashBag()->get("esito", array());
     }
     $form = $this->form_ricerca_rif();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
     }
     $entities = $this->getDoctrine()->getRepository("CasaFront2Bundle:Scheda")->scheda($data, $page);
     $entities2 = $this->getDoctrine()->getRepository("CasaFront2Bundle:Scheda")->scheda_pag($data);
     return array('form_ric' => $form->createView(), 'entities' => $entities, 'pag' => $entities2, 'esito' => $esito, 'page' => $page);
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Request::setLocale