Configuration is loaded before DIC is compiled before the request is actually processed, as it's accessible from Request
, you can't access locale in configuration.
If you don't mind one extra redirect, you can have an action that will redirect user after failed authentication to correct route:
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class SecurityController extends Controller {
public function failedAction() {
return $this->redirect($this->generateUrl('login_fail_localized'), [
'locale' => $this->getRequest()->getLocale()
]);
}
}
Set failure path to match it's route:
# routing.yml
login_fail:
pattern: /login_fail
defaults: { _controller: AcmeDemoBundle:Security:failed }
login_fail_localized:
pattern: /{locale}/login_fail
defaults: { _controller: ContactbeeProfileBundle:Profile:dashboard }