Skip to content

Commit f0c7eea

Browse files
committed
Add regions for Belarus
1 parent 21aa619 commit f0c7eea

File tree

2 files changed

+93
-2
lines changed

2 files changed

+93
-2
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Directory\Setup\Patch\Data;
9+
10+
use Magento\Directory\Setup\DataInstaller;
11+
use Magento\Directory\Setup\DataInstallerFactory;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
15+
/**
16+
* Add Regions for Belarus.
17+
*/
18+
class AddDataForBelarus implements DataPatchInterface
19+
{
20+
/**
21+
* @var ModuleDataSetupInterface
22+
*/
23+
private $moduleDataSetup;
24+
25+
/**
26+
* @var DataInstallerFactory
27+
*/
28+
private $dataInstallerFactory;
29+
30+
/**
31+
* @param ModuleDataSetupInterface $moduleDataSetup
32+
* @param DataInstallerFactory $dataInstallerFactory
33+
*/
34+
public function __construct(
35+
ModuleDataSetupInterface $moduleDataSetup,
36+
DataInstallerFactory $dataInstallerFactory
37+
) {
38+
$this->moduleDataSetup = $moduleDataSetup;
39+
$this->dataInstallerFactory = $dataInstallerFactory;
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function apply()
46+
{
47+
/** @var DataInstaller $dataInstaller */
48+
$dataInstaller = $this->dataInstallerFactory->create();
49+
$dataInstaller->addCountryRegions(
50+
$this->moduleDataSetup->getConnection(),
51+
$this->getDataForBelarus()
52+
);
53+
}
54+
55+
/**
56+
* Belarus regions data.
57+
*
58+
* @return array
59+
*/
60+
private function getDataForBelarus(): array
61+
{
62+
return [
63+
['BY', 'BY-BR', 'Bresckaja voblasć'],
64+
['BY', 'BY-HO', 'Homieĺskaja voblasć'],
65+
['BY', 'BY-HM', 'Horad Minsk'],
66+
['BY', 'BY-HR', 'Hrodzienskaja voblasć'],
67+
['BY', 'BY-MA', 'Mahilioŭskaja voblasć'],
68+
['BY', 'BY-MI', 'Minskaja voblasć'],
69+
['BY', 'BY-VI', 'Viciebskaja voblasć'],
70+
];
71+
}
72+
73+
/**
74+
* @inheritdoc
75+
*/
76+
public static function getDependencies()
77+
{
78+
return [
79+
InitializeDirectoryData::class,
80+
];
81+
}
82+
83+
/**
84+
* @inheritdoc
85+
*/
86+
public function getAliases()
87+
{
88+
return [];
89+
}
90+
}

dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testCountryHasRegions($countryId)
4444
*
4545
* @return array
4646
*/
47-
public function getCountryIdDataProvider():array
47+
public function getCountryIdDataProvider(): array
4848
{
4949
return [
5050
['countryId' => 'US'],
@@ -72,7 +72,8 @@ public function getCountryIdDataProvider():array
7272
['countryId' => 'SE'],
7373
['countryId' => 'GR'],
7474
['countryId' => 'DK'],
75-
['countryId' => 'AL']
75+
['countryId' => 'AL'],
76+
['countryId' => 'BY'],
7677
];
7778
}
7879
}

0 commit comments

Comments
 (0)