protected function applyUserLocale(UserInterface $user)
    {
        // Set the current language according to locale preference
        $locale = $user->getLocale();

        if (null === $lang = LangQuery::create()->findOneByLocale($locale)) {
            $lang = Lang::getDefaultLanguage();
        }

        $this->getSession()->setLang($lang);
    }
protected function applyUserLocale(UserInterface $user)
    {
        // Set the current language according to locale preference
        $locale = $user->getLocale();

        if (null === $lang = LangQuery::create()->findOneByLocale($locale)) {
            $lang = Lang::getDefaultLanguage();
        }

        $this->getSession()->setLang($lang);
    }
protected function applyUserLocale ( UserInterface $ user ) { // Set the current language according to locale preference $ locale = $ user -> getLocale ( ) ; if ( null === $ lang = LangQuery :: create ( ) -> findOneByLocale ( $ locale ) ) { $ lang = Lang :: getDefaultLanguage ( ) ; } $ this -> getSession ( ) -> setLang ( $ lang ) ; }
Save user locale preference in session.

@param UserInterface $user
Save user locale preference in session .