Controller/Front/CurrencyController.php
public function switchAction(Request $request, string $currency) : RedirectResponse
    {
        $result = $this->get('currency.repository')->findOneBy(['code' => $currency]);
        if (null !== $result) {
            $request->getSession()->set('_currency', $currency);
        }

        return new RedirectResponse($request->headers->get('referer'));
    }
public function switchAction(Request $request, string $currency) : RedirectResponse
    {
        $result = $this->get('currency.repository')->findOneBy(['code' => $currency]);
        if (null !== $result) {
            $request->getSession()->set('_currency', $currency);
        }

        return new RedirectResponse($request->headers->get('referer'));
    }
public function switchAction ( Request $ request , string $ currency ) : RedirectResponse { $ result = $ this -> get ( 'currency.repository' ) -> findOneBy ( [ 'code' => $ currency ] ) ; if ( null !== $ result ) { $ request -> getSession ( ) -> set ( '_currency' , $ currency ) ; } return new RedirectResponse ( $ request -> headers -> get ( 'referer' ) ) ; }
Sets new session currency

@param Request $request
@param string  $currency

@return RedirectResponse
Sets new session currency