Skip to content

Commit e3faa34

Browse files
authored
ENGCOM-3259: [Forwardport] 17516: added Australian states #18774
2 parents 8a113e5 + 4bed472 commit e3faa34

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Directory\Setup\Patch\Data;
10+
11+
use Magento\Directory\Setup\DataInstaller;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
15+
16+
/**
17+
* Adds Australian States
18+
*/
19+
class AddDataForAustralia implements DataPatchInterface, PatchVersionInterface
20+
{
21+
/**
22+
* @var ModuleDataSetupInterface
23+
*/
24+
private $moduleDataSetup;
25+
26+
/**
27+
* @var \Magento\Directory\Setup\DataInstallerFactory
28+
*/
29+
private $dataInstallerFactory;
30+
31+
/**
32+
* @param ModuleDataSetupInterface $moduleDataSetup
33+
* @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
34+
*/
35+
public function __construct(
36+
ModuleDataSetupInterface $moduleDataSetup,
37+
\Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
38+
) {
39+
$this->moduleDataSetup = $moduleDataSetup;
40+
$this->dataInstallerFactory = $dataInstallerFactory;
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public function apply()
47+
{
48+
/** @var DataInstaller $dataInstaller */
49+
$dataInstaller = $this->dataInstallerFactory->create();
50+
$dataInstaller->addCountryRegions(
51+
$this->moduleDataSetup->getConnection(),
52+
$this->getDataForAustralia()
53+
);
54+
}
55+
56+
/**
57+
* Australian states data.
58+
*
59+
* @return array
60+
*/
61+
private function getDataForAustralia()
62+
{
63+
return [
64+
['AU', 'ACT', 'Australian Capital Territory'],
65+
['AU', 'NSW', 'New South Wales'],
66+
['AU', 'VIC', 'Victoria'],
67+
['AU', 'QLD', 'Queensland'],
68+
['AU', 'SA', 'South Australia'],
69+
['AU', 'TAS', 'Tasmania'],
70+
['AU', 'WA', 'Western Australia'],
71+
['AU', 'NT', 'Northern Territory']
72+
];
73+
}
74+
75+
/**
76+
* @inheritdoc
77+
*/
78+
public static function getDependencies()
79+
{
80+
return [
81+
InitializeDirectoryData::class,
82+
AddDataForCroatia::class,
83+
AddDataForIndia::class,
84+
];
85+
}
86+
87+
/**
88+
* @inheritdoc
89+
*/
90+
public static function getVersion()
91+
{
92+
return '2.0.3';
93+
}
94+
95+
/**
96+
* @inheritdoc
97+
*/
98+
public function getAliases()
99+
{
100+
return [];
101+
}
102+
}

0 commit comments

Comments
 (0)