|
6 | 6 | namespace Magento\Framework\Locale;
|
7 | 7 |
|
8 | 8 | use Magento\Framework\App\Config\ScopeConfigInterface;
|
| 9 | +use Magento\Framework\App\DeploymentConfig; |
| 10 | +use Magento\Framework\App\ObjectManager; |
9 | 11 |
|
10 | 12 | class Resolver implements ResolverInterface
|
11 | 13 | {
|
@@ -52,6 +54,11 @@ class Resolver implements ResolverInterface
|
52 | 54 | */
|
53 | 55 | private $defaultLocalePath;
|
54 | 56 |
|
| 57 | + /** |
| 58 | + * @var DeploymentConfig |
| 59 | + */ |
| 60 | + private $deploymentConfig; |
| 61 | + |
55 | 62 | /**
|
56 | 63 | * @param ScopeConfigInterface $scopeConfig
|
57 | 64 | * @param string $defaultLocalePath
|
@@ -93,7 +100,10 @@ public function setDefaultLocale($locale)
|
93 | 100 | public function getDefaultLocale()
|
94 | 101 | {
|
95 | 102 | if (!$this->defaultLocale) {
|
96 |
| - $locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType); |
| 103 | + $locale = false; |
| 104 | + if ($this->getDeploymentConfig()->isAvailable() && $this->getDeploymentConfig()->isDbAvailable()) { |
| 105 | + $locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType); |
| 106 | + } |
97 | 107 | if (!$locale) {
|
98 | 108 | $locale = self::DEFAULT_LOCALE;
|
99 | 109 | }
|
@@ -159,4 +169,18 @@ public function revert()
|
159 | 169 | }
|
160 | 170 | return $result;
|
161 | 171 | }
|
| 172 | + |
| 173 | + /** |
| 174 | + * Retrieve Deployment Config |
| 175 | + * |
| 176 | + * @return DeploymentConfig |
| 177 | + */ |
| 178 | + private function getDeploymentConfig() |
| 179 | + { |
| 180 | + if (!$this->deploymentConfig) { |
| 181 | + $this->deploymentConfig = ObjectManager::getInstance()->get(DeploymentConfig::class); |
| 182 | + } |
| 183 | + |
| 184 | + return $this->deploymentConfig; |
| 185 | + } |
162 | 186 | }
|
0 commit comments