Skip to content

Commit af13144

Browse files
committed
Merge branch 'feature/36346-czechia-regions' of github.com:Tomasz-Silpion/magento2 into 2.4-develop-prs
2 parents e027cd2 + 6fb61c3 commit af13144

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 Czech Republic States
17+
*/
18+
class AddDataForCzechia 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->getDataForCzechia()
52+
);
53+
54+
return $this;
55+
}
56+
57+
/**
58+
* Czechia states data.
59+
*
60+
* @return array
61+
*/
62+
private function getDataForCzechia()
63+
{
64+
return [
65+
['CZ', 'CZ-10', 'Praha, Hlavní město'],
66+
['CZ', 'CZ-20', 'Středočeský kraj'],
67+
['CZ', 'CZ-31', 'Jihočeský kraj'],
68+
['CZ', 'CZ-32', 'Plzeňský kraj'],
69+
['CZ', 'CZ-41', 'Karlovarský kraj'],
70+
['CZ', 'CZ-42', 'Ústecký kraj'],
71+
['CZ', 'CZ-51', 'Liberecký kraj'],
72+
['CZ', 'CZ-52', 'Královéhradecký kraj'],
73+
['CZ', 'CZ-53', 'Pardubický kraj'],
74+
['CZ', 'CZ-63', 'Kraj Vysočina'],
75+
['CZ', 'CZ-64', 'Jihomoravský kraj'],
76+
['CZ', 'CZ-71', 'Olomoucký kraj'],
77+
['CZ', 'CZ-72', 'Zlínský kraj'],
78+
['CZ', 'CZ-80', 'Moravskoslezský kraj'],
79+
];
80+
}
81+
82+
/**
83+
* @inheritdoc
84+
*/
85+
public static function getDependencies()
86+
{
87+
return [
88+
InitializeDirectoryData::class,
89+
];
90+
}
91+
92+
/**
93+
* @inheritdoc
94+
*/
95+
public function getAliases()
96+
{
97+
return [];
98+
}
99+
}

0 commit comments

Comments
 (0)