How do you set the user culture during the signin process which is handled by the sfDoctrineGuardPlugin? Each user can set their preferred language which is stored in the sfGuardUserProfile table.
Originally I had thought about overriding the executeSignin()
function by doing something similar to this:
public function executeSignin(sfWebRequest $request)
{
$this->getUser()->setCulture($this->getUser()->getGuardUser()->getProfile()->getLanguage());
parent::executeSignin($request);
}
but obviously I can't do that since I don't have access to the GuardUser object before the parent function is executed.
Then I thought about creating a postExectute()
function similar to this:
public function postExecute()
{
if($this->getUser()->isAuthenticated()){
//SET USER CULTURE
}
}
but again this can't work because the signin function does a redirect so postExecute()
will never run.
I cannot put my logic to set the culture on the default page after login, because the user is not always redirected to the same page or even the same module.
I will go on something easier than re-create the action.
In your file /apps/[your app]/lib/user/myUser.class.php
which extends sfGuardSecurityUser
:
You can override the signIn
function like that :
public function signIn($user, $remember = false, $con = null)
{
parent::signin($user, $remember, $con);
$this->setCulture($user->getProfile()->getLanguage());
}
So every time a user is log in, it will have its culture setted.