-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' of github.com:magento-commerce/magento2ce …
…into GL_PR_2021-10-05
- Loading branch information
Showing
21 changed files
with
1,252 additions
and
31 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/code/Magento/Customer/ViewModel/Address/RegionProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Customer\ViewModel\Address; | ||
|
||
use Magento\Directory\Model\RegionProvider as DirectoryRegionProvider; | ||
use Magento\Framework\View\Element\Block\ArgumentInterface; | ||
|
||
class RegionProvider implements ArgumentInterface | ||
{ | ||
|
||
/** | ||
* @var DirectoryRegionProvider | ||
*/ | ||
private $directoryRegionProvider; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param DirectoryRegionProvider $directoryRegionProvider | ||
*/ | ||
public function __construct( | ||
DirectoryRegionProvider $directoryRegionProvider | ||
) { | ||
$this->directoryRegionProvider = $directoryRegionProvider; | ||
} | ||
|
||
/** | ||
* Get region data json | ||
* | ||
* @return string | ||
*/ | ||
public function getRegionJson(): string | ||
{ | ||
return $this->directoryRegionProvider->getRegionJson(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Directory\Model; | ||
|
||
use Magento\Directory\Helper\Data as DataHelper; | ||
use Magento\Framework\Serialize\Serializer\Json as JsonSerializer; | ||
|
||
class RegionProvider | ||
{ | ||
/** | ||
* @var RegionsArray | ||
*/ | ||
private $regions; | ||
/** | ||
* @var DataHelper | ||
*/ | ||
private $directoryHelper; | ||
/** | ||
* @var JsonSerializer | ||
*/ | ||
private $jsonSerializer; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param DataHelper $directoryHelper | ||
* @param JsonSerializer $jsonSerializer | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function __construct( | ||
DataHelper $directoryHelper, | ||
JsonSerializer $jsonSerializer | ||
) { | ||
$this->directoryHelper= $directoryHelper; | ||
$this->jsonSerializer = $jsonSerializer; | ||
} | ||
|
||
/** | ||
* Get region data json | ||
* | ||
* @return string | ||
*/ | ||
public function getRegionJson(): string | ||
{ | ||
$regions = $this->getRegions(); | ||
return $this->jsonSerializer->serialize($regions); | ||
} | ||
|
||
/** | ||
* Get regions array | ||
* | ||
* @return array | ||
*/ | ||
private function getRegions() : array | ||
{ | ||
if (!$this->regions) { | ||
$regions = $this->directoryHelper->getRegionData(); | ||
$this->regions['config'] = $regions['config']; | ||
unset($regions['config']); | ||
foreach ($regions as $countryCode => $countryRegions) { | ||
foreach ($countryRegions as $regionId => $regionData) { | ||
$this->regions[$countryCode][] = [ | ||
'id' => $regionId, | ||
'name' => $regionData['name'], | ||
'code' => $regionData['code'] | ||
]; | ||
} | ||
} | ||
} | ||
return $this->regions; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/code/Magento/Directory/view/frontend/requirejs-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
var config = { | ||
map: { | ||
'*': { | ||
directoryRegionUpdater: 'Magento_Directory/js/region-updater' | ||
} | ||
} | ||
}; |
Oops, something went wrong.