Skip to content

Commit 61b94c5

Browse files
authored
ENGCOM-7536: Feature bulgarian country regions #27957
2 parents c851cee + 6b08ff2 commit 61b94c5

File tree

2 files changed

+117
-1
lines changed

2 files changed

+117
-1
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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 Bulgaria States
17+
*/
18+
class AddDataForBulgaria implements DataPatchInterface
19+
{
20+
/**
21+
* @var ModuleDataSetupInterface
22+
*/
23+
private $moduleDataSetup;
24+
25+
/**
26+
* @var DataInstallerFactory
27+
*/
28+
private $dataInstallerFactory;
29+
30+
/**
31+
* AddDataForBulgaria constructor.
32+
*
33+
* @param ModuleDataSetupInterface $moduleDataSetup
34+
* @param DataInstallerFactory $dataInstallerFactory
35+
*/
36+
public function __construct(
37+
ModuleDataSetupInterface $moduleDataSetup,
38+
DataInstallerFactory $dataInstallerFactory
39+
) {
40+
$this->moduleDataSetup = $moduleDataSetup;
41+
$this->dataInstallerFactory = $dataInstallerFactory;
42+
}
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
public function apply()
48+
{
49+
/** @var DataInstaller $dataInstaller */
50+
$dataInstaller = $this->dataInstallerFactory->create();
51+
$dataInstaller->addCountryRegions(
52+
$this->moduleDataSetup->getConnection(),
53+
$this->getDataForBulgaria()
54+
);
55+
56+
return $this;
57+
}
58+
59+
/**
60+
* Bulgarian states data.
61+
*
62+
* @return array
63+
*/
64+
private function getDataForBulgaria()
65+
{
66+
return [
67+
['BG', 'BG-01', 'Blagoevgrad'],
68+
['BG', 'BG-02', 'Burgas'],
69+
['BG', 'BG-03', 'Varna'],
70+
['BG', 'BG-04', 'Veliko Tarnovo'],
71+
['BG', 'BG-05', 'Vidin'],
72+
['BG', 'BG-06', 'Vratsa'],
73+
['BG', 'BG-07', 'Gabrovo'],
74+
['BG', 'BG-08', 'Dobrich'],
75+
['BG', 'BG-09', 'Kardzhali'],
76+
['BG', 'BG-10', 'Kyustendil'],
77+
['BG', 'BG-11', 'Lovech'],
78+
['BG', 'BG-12', 'Montana'],
79+
['BG', 'BG-13', 'Pazardzhik'],
80+
['BG', 'BG-14', 'Pernik'],
81+
['BG', 'BG-15', 'Pleven'],
82+
['BG', 'BG-16', 'Plovdiv'],
83+
['BG', 'BG-17', 'Razgrad'],
84+
['BG', 'BG-18', 'Ruse'],
85+
['BG', 'BG-19', 'Silistra'],
86+
['BG', 'BG-20', 'Sliven'],
87+
['BG', 'BG-21', 'Smolyan'],
88+
['BG', 'BG-22', 'Sofia City'],
89+
['BG', 'BG-23', 'Sofia Province'],
90+
['BG', 'BG-24', 'Stara Zagora'],
91+
['BG', 'BG-25', 'Targovishte'],
92+
['BG', 'BG-26', 'Haskovo'],
93+
['BG', 'BG-27', 'Shumen'],
94+
['BG', 'BG-28', 'Yambol'],
95+
];
96+
}
97+
98+
/**
99+
* @inheritdoc
100+
*/
101+
public static function getDependencies()
102+
{
103+
return [
104+
InitializeDirectoryData::class,
105+
];
106+
}
107+
108+
/**
109+
* @inheritdoc
110+
*/
111+
public function getAliases()
112+
{
113+
return [];
114+
}
115+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public function getCountryIdDataProvider():array
5656
['countryId' => 'CO'],
5757
['countryId' => 'MX'],
5858
['countryId' => 'PL'],
59-
['countryId' => 'IT']
59+
['countryId' => 'IT'],
60+
['countryId' => 'BG']
6061
];
6162
}
6263
}

0 commit comments

Comments
 (0)