Skip to content

Commit b1d55f8

Browse files
ENGCOM-4482: Fix #21692 - logic in constructor of address validator #21693
- Merge Pull Request #21693 from Bartlomiejsz/magento2:feature/fix_21692_incorrect_constructor - Merged commits: 1. 28b047e 2. b92ffa2 3. fda4377 4. b2004c3 5. b86f981 6. 73d88aa
2 parents a55c94f + 73d88aa commit b1d55f8

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

app/code/Magento/Sales/Model/Order/Address/Validator.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ public function __construct(
6161
$this->countryFactory = $countryFactory;
6262
$this->eavConfig = $eavConfig ?: ObjectManager::getInstance()
6363
->get(EavConfig::class);
64+
}
65+
66+
/**
67+
*
68+
* @param \Magento\Sales\Model\Order\Address $address
69+
* @return array
70+
*/
71+
public function validate(Address $address)
72+
{
73+
$warnings = [];
6474

6575
if ($this->isTelephoneRequired()) {
6676
$this->required['telephone'] = 'Phone Number';
@@ -73,16 +83,7 @@ public function __construct(
7383
if ($this->isFaxRequired()) {
7484
$this->required['fax'] = 'Fax';
7585
}
76-
}
7786

78-
/**
79-
*
80-
* @param \Magento\Sales\Model\Order\Address $address
81-
* @return array
82-
*/
83-
public function validate(Address $address)
84-
{
85-
$warnings = [];
8687
foreach ($this->required as $code => $label) {
8788
if (!$address->hasData($code)) {
8889
$warnings[] = sprintf('"%s" is required. Enter and try again.', $label);

lib/internal/Magento/Framework/Locale/Format.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getPriceFormat($localeCode = null, $currencyCode = null)
100100
}
101101

102102
$formatter = new \NumberFormatter(
103-
$localeCode . '@currency=' . $currency->getCode(),
103+
$currency->getCode() ? $localeCode . '@currency=' . $currency->getCode() : $localeCode,
104104
\NumberFormatter::CURRENCY
105105
);
106106
$format = $formatter->getPattern();

lib/internal/Magento/Framework/Locale/Resolver.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Framework\Locale;
77

88
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
use Magento\Framework\App\DeploymentConfig;
10+
use Magento\Framework\App\ObjectManager;
911

1012
class Resolver implements ResolverInterface
1113
{
@@ -52,21 +54,29 @@ class Resolver implements ResolverInterface
5254
*/
5355
private $defaultLocalePath;
5456

57+
/**
58+
* @var DeploymentConfig
59+
*/
60+
private $deploymentConfig;
61+
5562
/**
5663
* @param ScopeConfigInterface $scopeConfig
5764
* @param string $defaultLocalePath
5865
* @param string $scopeType
5966
* @param mixed $locale
67+
* @param DeploymentConfig|null $deploymentConfig
6068
*/
6169
public function __construct(
6270
ScopeConfigInterface $scopeConfig,
6371
$defaultLocalePath,
6472
$scopeType,
65-
$locale = null
73+
$locale = null,
74+
DeploymentConfig $deploymentConfig = null
6675
) {
6776
$this->scopeConfig = $scopeConfig;
6877
$this->defaultLocalePath = $defaultLocalePath;
6978
$this->scopeType = $scopeType;
79+
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class);
7080
$this->setLocale($locale);
7181
}
7282

@@ -93,7 +103,10 @@ public function setDefaultLocale($locale)
93103
public function getDefaultLocale()
94104
{
95105
if (!$this->defaultLocale) {
96-
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
106+
$locale = false;
107+
if ($this->deploymentConfig->isAvailable() && $this->deploymentConfig->isDbAvailable()) {
108+
$locale = $this->scopeConfig->getValue($this->getDefaultLocalePath(), $this->scopeType);
109+
}
97110
if (!$locale) {
98111
$locale = self::DEFAULT_LOCALE;
99112
}

0 commit comments

Comments
 (0)