66namespace Magento \Framework \Locale ;
77
88use Magento \Framework \App \Config \ScopeConfigInterface ;
9+ use Magento \Framework \App \DeploymentConfig ;
10+ use Magento \Framework \App \ObjectManager ;
911
12+ /**
13+ * Manages locale config information.
14+ */
1015class Resolver implements ResolverInterface
1116{
1217 /**
@@ -52,34 +57,42 @@ class Resolver implements ResolverInterface
5257 */
5358 private $ defaultLocalePath ;
5459
60+ /**
61+ * @var DeploymentConfig
62+ */
63+ private $ deploymentConfig ;
64+
5565 /**
5666 * @param ScopeConfigInterface $scopeConfig
5767 * @param string $defaultLocalePath
5868 * @param string $scopeType
5969 * @param mixed $locale
70+ * @param DeploymentConfig|null $deploymentConfig
6071 */
6172 public function __construct (
6273 ScopeConfigInterface $ scopeConfig ,
6374 $ defaultLocalePath ,
6475 $ scopeType ,
65- $ locale = null
76+ $ locale = null ,
77+ DeploymentConfig $ deploymentConfig = null
6678 ) {
6779 $ this ->scopeConfig = $ scopeConfig ;
6880 $ this ->defaultLocalePath = $ defaultLocalePath ;
6981 $ this ->scopeType = $ scopeType ;
82+ $ this ->deploymentConfig = $ deploymentConfig ?: ObjectManager::getInstance ()->create (DeploymentConfig::class);
7083 $ this ->setLocale ($ locale );
7184 }
7285
7386 /**
74- * { @inheritdoc}
87+ * @inheritdoc
7588 */
7689 public function getDefaultLocalePath ()
7790 {
7891 return $ this ->defaultLocalePath ;
7992 }
8093
8194 /**
82- * { @inheritdoc}
95+ * @inheritdoc
8396 */
8497 public function setDefaultLocale ($ locale )
8598 {
@@ -88,12 +101,15 @@ public function setDefaultLocale($locale)
88101 }
89102
90103 /**
91- * { @inheritdoc}
104+ * @inheritdoc
92105 */
93106 public function getDefaultLocale ()
94107 {
95108 if (!$ this ->defaultLocale ) {
96- $ locale = $ this ->scopeConfig ->getValue ($ this ->getDefaultLocalePath (), $ this ->scopeType );
109+ $ locale = false ;
110+ if ($ this ->deploymentConfig ->isAvailable () && $ this ->deploymentConfig ->isDbAvailable ()) {
111+ $ locale = $ this ->scopeConfig ->getValue ($ this ->getDefaultLocalePath (), $ this ->scopeType );
112+ }
97113 if (!$ locale ) {
98114 $ locale = self ::DEFAULT_LOCALE ;
99115 }
@@ -103,7 +119,7 @@ public function getDefaultLocale()
103119 }
104120
105121 /**
106- * { @inheritdoc}
122+ * @inheritdoc
107123 */
108124 public function setLocale ($ locale = null )
109125 {
@@ -116,7 +132,7 @@ public function setLocale($locale = null)
116132 }
117133
118134 /**
119- * { @inheritdoc}
135+ * @inheritdoc
120136 */
121137 public function getLocale ()
122138 {
@@ -127,7 +143,7 @@ public function getLocale()
127143 }
128144
129145 /**
130- * { @inheritdoc}
146+ * @inheritdoc
131147 */
132148 public function emulate ($ scopeId )
133149 {
@@ -147,7 +163,7 @@ public function emulate($scopeId)
147163 }
148164
149165 /**
150- * { @inheritdoc}
166+ * @inheritdoc
151167 */
152168 public function revert ()
153169 {
0 commit comments