Skip to content

Commit 45fc993

Browse files
Merge remote-tracking branch '33189/2.4-develop' into comm_voted_v3
2 parents 2662b0f + 0093630 commit 45fc993

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
15+
16+
/**
17+
* Add Costa Rica States/Regions
18+
*/
19+
class AddDataForCostaRica implements DataPatchInterface, PatchVersionInterface
20+
{
21+
/**
22+
* @var ModuleDataSetupInterface
23+
*/
24+
private $moduleDataSetup;
25+
26+
/**
27+
* @var DataInstallerFactory
28+
*/
29+
private $dataInstallerFactory;
30+
31+
/**
32+
* @param ModuleDataSetupInterface $moduleDataSetup
33+
* @param DataInstallerFactory $dataInstallerFactory
34+
*/
35+
public function __construct(
36+
ModuleDataSetupInterface $moduleDataSetup,
37+
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->getDataForCostaRica()
53+
);
54+
55+
return $this;
56+
}
57+
58+
/**
59+
* Costa Rica states data.Pura Vida :)
60+
*
61+
* @return array
62+
*/
63+
private function getDataForCostaRica(): array
64+
{
65+
return [
66+
['CR', 'CR-SJ', 'San José'],
67+
['CR', 'CR-AL', 'Alajuela'],
68+
['CR', 'CR-CA', 'Cartago'],
69+
['CR', 'CR-HE', 'Heredia'],
70+
['CR', 'CR-GU', 'Guanacaste'],
71+
['CR', 'CR-PU', 'Puntarenas'],
72+
['CR', 'CR-LI', 'Limón']
73+
];
74+
}
75+
76+
/**
77+
* @inheritdoc
78+
*/
79+
public static function getDependencies()
80+
{
81+
return [
82+
InitializeDirectoryData::class,
83+
];
84+
}
85+
86+
/**
87+
* @inheritdoc
88+
*/
89+
public function getAliases()
90+
{
91+
return [];
92+
}
93+
94+
/**
95+
* Get version
96+
*
97+
* @return string
98+
*/
99+
public static function getVersion()
100+
{
101+
return '2.4.2';
102+
}
103+
}

0 commit comments

Comments
 (0)