Skip to content

Commit

Permalink
Move deploymentConfig to constructor in Locale Resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartlomiejsz committed Mar 18, 2019
1 parent b92ffa2 commit fda4377
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions lib/internal/Magento/Framework/Locale/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ class Resolver implements ResolverInterface
* @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 Down Expand Up @@ -101,7 +104,7 @@ public function getDefaultLocale()
{
if (!$this->defaultLocale) {
$locale = false;
if ($this->getDeploymentConfig()->isAvailable() && $this->getDeploymentConfig()->isDbAvailable()) {
if ($this->deploymentConfig->isAvailable() && $this->deploymentConfig->isDbAvailable()) {
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
}
if (!$locale) {
Expand Down Expand Up @@ -169,18 +172,4 @@ public function revert()
}
return $result;
}

/**
* Retrieve Deployment Config
*
* @return DeploymentConfig
*/
private function getDeploymentConfig()
{
if (!$this->deploymentConfig) {
$this->deploymentConfig = ObjectManager::getInstance()->get(DeploymentConfig::class);
}

return $this->deploymentConfig;
}
}

0 comments on commit fda4377

Please sign in to comment.