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
{
@@ -47,21 +49,29 @@ class Resolver implements ResolverInterface
47
49
*/
48
50
protected $ emulatedLocales = [];
49
51
52
+ /**
53
+ * @var DeploymentConfig
54
+ */
55
+ private $ deploymentConfig ;
56
+
50
57
/**
51
58
* @param ScopeConfigInterface $scopeConfig
52
59
* @param string $defaultLocalePath
53
60
* @param string $scopeType
54
61
* @param mixed $locale
62
+ * @param DeploymentConfig|null $deploymentConfig
55
63
*/
56
64
public function __construct (
57
65
ScopeConfigInterface $ scopeConfig ,
58
66
$ defaultLocalePath ,
59
67
$ scopeType ,
60
- $ locale = null
68
+ $ locale = null ,
69
+ DeploymentConfig $ deploymentConfig = null
61
70
) {
62
71
$ this ->scopeConfig = $ scopeConfig ;
63
72
$ this ->defaultLocalePath = $ defaultLocalePath ;
64
73
$ this ->scopeType = $ scopeType ;
74
+ $ this ->deploymentConfig = $ deploymentConfig ?: ObjectManager::getInstance ()->create (DeploymentConfig::class);
65
75
$ this ->setLocale ($ locale );
66
76
}
67
77
@@ -88,7 +98,10 @@ public function setDefaultLocale($locale)
88
98
public function getDefaultLocale ()
89
99
{
90
100
if (!$ this ->defaultLocale ) {
91
- $ locale = $ this ->scopeConfig ->getValue ($ this ->getDefaultLocalePath (), $ this ->scopeType );
101
+ $ locale = false ;
102
+ if ($ this ->deploymentConfig ->isAvailable () && $ this ->deploymentConfig ->isDbAvailable ()) {
103
+ $ locale = $ this ->scopeConfig ->getValue ($ this ->getDefaultLocalePath (), $ this ->scopeType );
104
+ }
92
105
if (!$ locale ) {
93
106
$ locale = self ::DEFAULT_LOCALE ;
94
107
}
0 commit comments