Skip to content

Commit f634144

Browse files
authored
Add data for Costa Rica
Add Costa Rica states data.
1 parent 89939d3 commit f634144

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 Costa Rica States/Regions
17+
*/
18+
class AddDataForCostaRica 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->getDataForCostaRica()
52+
);
53+
54+
return $this;
55+
}
56+
57+
/**
58+
* Costa Rica states data.
59+
* 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+
}

0 commit comments

Comments
 (0)