Merge branch 'master' into tax

This commit is contained in:
Etienne Roudeix
2013-09-11 09:21:28 +02:00
2 changed files with 20 additions and 4 deletions

View File

@@ -47,7 +47,12 @@ class Session extends BaseSession
*/ */
public function getLang($forceDefault = true) public function getLang($forceDefault = true)
{ {
return $this->get("thelia.current.lang", $forceDefault ? Lang::getDefaultLanguage():null); $lang = $this->get("thelia.current.lang");
if(null === $lang && $forceDefault)
{
$lang = Lang::getDefaultLanguage();
}
return $lang;
} }
public function setLang(Lang $lang) public function setLang(Lang $lang)
@@ -59,7 +64,12 @@ class Session extends BaseSession
public function getAdminEditionLang() public function getAdminEditionLang()
{ {
return $this->get('thelia.admin.edition.lang', Lang::getDefaultLanguage()); $lang = $this->get('thelia.admin.edition.lang');
if (null === $lang) {
$lang = Lang::getDefaultLanguage();
}
return $lang;
} }
public function setAdminEditionLang($langId) public function setAdminEditionLang($langId)
@@ -76,7 +86,13 @@ class Session extends BaseSession
public function getCurrency($forceDefault = true) public function getCurrency($forceDefault = true)
{ {
return $this->get("thelia.current.currency", $forceDefault ? Currency::getDefaultCurrency():null); $currency = $this->get("thelia.current.currency");
if(null === $currency && $forceDefault)
{
$currency = Currency::getDefaultCurrency();
}
return $currency;
} }
// -- Customer user -------------------------------------------------------- // -- Customer user --------------------------------------------------------

View File

@@ -110,7 +110,7 @@ class ModelCriteriaTools
{ {
// If a lang has been requested, find the related Lang object, and get the locale // If a lang has been requested, find the related Lang object, and get the locale
if ($requestedLangId !== null) { if ($requestedLangId !== null) {
$localeSearch = LangQuery::create()->findOneById($requestedLangId); $localeSearch = LangQuery::create()->findPk($requestedLangId);
if ($localeSearch === null) { if ($localeSearch === null) {
throw new \InvalidArgumentException(sprintf('Incorrect lang argument given : lang ID %d not found', $requestedLangId)); throw new \InvalidArgumentException(sprintf('Incorrect lang argument given : lang ID %d not found', $requestedLangId));