diff options
author | emkael <emkael@tlen.pl> | 2016-06-10 11:51:21 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-06-10 11:51:21 +0200 |
commit | 388935eecec63a1f434b3f416867d4d158d52728 (patch) | |
tree | 2ad6b76d84b68c4e9afec25bb777e001ffb23aa0 /app | |
parent | 2b5232a1193356e4bb9ad2d9234735890cd32eaa (diff) |
* user facade getter/setter for language preference
Diffstat (limited to 'app')
-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; + } + } ?> |