From be033fd66aeb74a95b6d6f6f3a62191d6d4a041a Mon Sep 17 00:00:00 2001 From: Shefik Date: Sat, 10 Dec 2016 04:18:33 -0500 Subject: [PATCH] Moving conditional statement. If the locale resolver was not able to determine a locale, then all efforts to make an informed decision have failed. Just display something as a last resort. Avoids a possible exception, if the requested language is an empty string - JMS\I18nRoutingBundle\Exception\NotAcceptableLanguageException: The requested language "" was not available. --- Router/I18nRouter.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Router/I18nRouter.php b/Router/I18nRouter.php index 42dd248..d2fadee 100644 --- a/Router/I18nRouter.php +++ b/Router/I18nRouter.php @@ -197,12 +197,12 @@ private function matchI18n(array $params, $url) $currentLocale = $this->localeResolver->resolveLocale( $request, $params['_locales'] ); - - // If the locale resolver was not able to determine a locale, then all efforts to - // make an informed decision have failed. Just display something as a last resort. - if (!$currentLocale) { - $currentLocale = reset($params['_locales']); - } + } + + // If the locale resolver was not able to determine a locale, then all efforts to + // make an informed decision have failed. Just display something as a last resort. + if (!$currentLocale) { + $currentLocale = reset($params['_locales']); } if (!in_array($currentLocale, $params['_locales'], true)) {