added cache to get default country and currency
This commit is contained in:
@@ -14,15 +14,20 @@ class Currency extends BaseCurrency
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
protected static $defaultCurrency = null;
|
||||
|
||||
public static function getDefaultCurrency()
|
||||
{
|
||||
$currency = CurrencyQuery::create()->findOneByByDefault(1);
|
||||
if (null === self::$defaultCurrency) {
|
||||
|
||||
if (null === $currency) {
|
||||
throw new \RuntimeException("No default currency is defined. Please define one.");
|
||||
self::$defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
|
||||
|
||||
if (self::$defaultCurrency == null) {
|
||||
throw new \RuntimeException("No default currency is defined. Please define one.");
|
||||
}
|
||||
}
|
||||
|
||||
return $currency;
|
||||
return self::$defaultCurrency;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user