for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\ShopBundle\Locale;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* @author Kamil Kokot <[email protected]>
final class UrlBasedLocaleSwitcher implements LocaleSwitcherInterface
{
* @var UrlGeneratorInterface
private $urlGenerator;
* @param UrlGeneratorInterface $urlGenerator
public function __construct(UrlGeneratorInterface $urlGenerator)
$this->urlGenerator = $urlGenerator;
}
* {@inheritdoc}
public function handle(Request $request, $localeCode)
return new RedirectResponse($this->urlGenerator->generate('sylius_shop_homepage', ['_locale' => $localeCode]));