Skip to content

Commit

Permalink
Don't check default locale if Magento is not installed, fix NumberFor…
Browse files Browse the repository at this point in the history
…matter initialization when no currency is set
  • Loading branch information
Bartlomiejsz committed Mar 18, 2019
1 parent 068eedf commit 8a4cfa4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Locale/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function getPriceFormat($localeCode = null, $currencyCode = null)
}

$formatter = new \NumberFormatter(
$localeCode . '@currency=' . $currency->getCode(),
$currency->getCode() ? $localeCode . '@currency=' . $currency->getCode() : $localeCode,
\NumberFormatter::CURRENCY
);
$format = $formatter->getPattern();
Expand Down
17 changes: 15 additions & 2 deletions lib/internal/Magento/Framework/Locale/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
namespace Magento\Framework\Locale;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ObjectManager;

class Resolver implements ResolverInterface
{
Expand Down Expand Up @@ -47,21 +49,29 @@ class Resolver implements ResolverInterface
*/
protected $emulatedLocales = [];

/**
* @var DeploymentConfig
*/
private $deploymentConfig;

/**
* @param ScopeConfigInterface $scopeConfig
* @param string $defaultLocalePath
* @param string $scopeType
* @param mixed $locale
* @param DeploymentConfig|null $deploymentConfig
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
$defaultLocalePath,
$scopeType,
$locale = null
$locale = null,
DeploymentConfig $deploymentConfig = null
) {
$this->scopeConfig = $scopeConfig;
$this->defaultLocalePath = $defaultLocalePath;
$this->scopeType = $scopeType;
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class);
$this->setLocale($locale);
}

Expand All @@ -88,7 +98,10 @@ public function setDefaultLocale($locale)
public function getDefaultLocale()
{
if (!$this->defaultLocale) {
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
$locale = false;
if ($this->deploymentConfig->isAvailable() && $this->deploymentConfig->isDbAvailable()) {
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
}
if (!$locale) {
$locale = self::DEFAULT_LOCALE;
}
Expand Down

0 comments on commit 8a4cfa4

Please sign in to comment.