src/Controller/Admin/LocaleController.php line 33

Open in your IDE?
  1. <?php 
  2. namespace App\Controller\Admin;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Translation\TranslatorInterface;
  9. class LocaleController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("setlocale/{language}", name="setlocale")
  13.      */
  14.     public function setLocaleAction(Request $request,$language null)
  15.     {
  16.         if($language != null)
  17.         {
  18.             $request->getSession()->set('_locale'$language);
  19.         }
  20.         $url $request->headers->get("referer");
  21.         return new RedirectResponse($url);
  22.        //return $this->redirectToRoute('index_page_home');
  23.     
  24.     /**
  25.      * @Route("lang/{language}", name="setlocale_langauge")
  26.      */
  27.     public function setLocaleLangAction(Request $request,$language null)
  28.     {
  29.         if($language != null)
  30.         {
  31.             $request->getSession()->set('_locale'$language);
  32.         }
  33.         // $url = $request->headers->get("referer");
  34.         // return new RedirectResponse($url);
  35.         return $this->redirectToRoute('index_page_home');
  36.     } 
  37. }