diff options
-rw-r--r-- | app/frontend/facades/UserFacade.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/frontend/facades/UserFacade.php b/app/frontend/facades/UserFacade.php index 1604a70..864fb58 100644 --- a/app/frontend/facades/UserFacade.php +++ b/app/frontend/facades/UserFacade.php @@ -4,6 +4,7 @@ Prado::using('Application.facades.Facade'); Prado::using('Application.user.DbUser'); Prado::using('Application.model.User'); Prado::using('Application.dto.TimezoneDTO'); +Prado::using('Application.dto.LanguageDTO'); class UserFacade extends Facade { @@ -73,6 +74,29 @@ class UserFacade extends Facade { return new TimezoneDTO(date_default_timezone_get()); } + public function setLanguagePreference(DbUser $user, string $lang) { + if ($user->IsGuest) { + throw new TInvlaidDataException( + Prado::localize( + 'Language preference change impossible for guest user' + ) + ); + } + $user->DbRecord->Language = $lang; + $user->DbRecord->save(); + } + + public function getLanguagePreference(DbUser $user) { + if (!$user->IsGuest) { + try { + if ($user->DbRecord->Language) { + return new LanguageDTO($user->DbRecord->Language); + } + } catch(Exception $e) {} + } + return NULL; + } + } ?> |