vendor/sonata-project/translation-bundle/src/Action/SwitchLocaleAction.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the Sonata Project package.
  5.  *
  6.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Sonata\TranslationBundle\Action;
  12. use Symfony\Component\HttpFoundation\RedirectResponse;
  13. use Symfony\Component\HttpFoundation\Request;
  14. /**
  15.  * @author Jonathan Vautrin <jvautrin@pro-info.be>
  16.  */
  17. final class SwitchLocaleAction
  18. {
  19.     public function __invoke(Request $requeststring $locale): RedirectResponse
  20.     {
  21.         $request->getSession()->set('_locale'$locale);
  22.         return new RedirectResponse($request->headers->get('referer''/'));
  23.     }
  24. }