|
| 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 Mexican States |
| 18 | + */ |
| 19 | +class AddDataForMexico 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->getDataForMexico() |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * Mexican states data. |
| 58 | + * |
| 59 | + * @return array |
| 60 | + */ |
| 61 | + private function getDataForMexico() |
| 62 | + { |
| 63 | + return [ |
| 64 | + ['MX', 'AGU', 'Aguascalientes'], |
| 65 | + ['MX', 'BCN', 'Baja California'], |
| 66 | + ['MX', 'BCS', 'Baja California Sur'], |
| 67 | + ['MX', 'CAM', 'Campeche'], |
| 68 | + ['MX', 'CHP', 'Chiapas'], |
| 69 | + ['MX', 'CHH', 'Chihuahua'], |
| 70 | + ['MX', 'CMX', 'Ciudad de México'], |
| 71 | + ['MX', 'COA', 'Coahuila'], |
| 72 | + ['MX', 'COL', 'Colima'], |
| 73 | + ['MX', 'DUR', 'Durango'], |
| 74 | + ['MX', 'MEX', 'Estado de México'], |
| 75 | + ['MX', 'GUA', 'Guanajuato'], |
| 76 | + ['MX', 'GRO', 'Guerrero'], |
| 77 | + ['MX', 'HID', 'Hidalgo'], |
| 78 | + ['MX', 'JAL', 'Jalisco'], |
| 79 | + ['MX', 'MIC', 'Michoacán'], |
| 80 | + ['MX', 'MOR', 'Morelos'], |
| 81 | + ['MX', 'NAY', 'Nayarit'], |
| 82 | + ['MX', 'NLE', 'Nuevo León'], |
| 83 | + ['MX', 'OAX', 'Oaxaca'], |
| 84 | + ['MX', 'PUE', 'Puebla'], |
| 85 | + ['MX', 'QUE', 'Querétaro'], |
| 86 | + ['MX', 'ROO', 'Quintana Roo'], |
| 87 | + ['MX', 'SLP', 'San Luis Potosí'], |
| 88 | + ['MX', 'SIN', 'Sinaloa'], |
| 89 | + ['MX', 'SON', 'Sonora'], |
| 90 | + ['MX', 'TAB', 'Tabasco'], |
| 91 | + ['MX', 'TAM', 'Tamaulipas'], |
| 92 | + ['MX', 'TLA', 'Tlaxcala'], |
| 93 | + ['MX', 'VER', 'Veracruz'], |
| 94 | + ['MX', 'YUC', 'Yucatán'], |
| 95 | + ['MX', 'ZAC', 'Zacatecas'] |
| 96 | + ]; |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * @inheritdoc |
| 101 | + */ |
| 102 | + public static function getDependencies() |
| 103 | + { |
| 104 | + return [ |
| 105 | + InitializeDirectoryData::class, |
| 106 | + AddDataForAustralia::class, |
| 107 | + AddDataForCroatia::class, |
| 108 | + AddDataForIndia::class, |
| 109 | + ]; |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * @inheritdoc |
| 114 | + */ |
| 115 | + public static function getVersion() |
| 116 | + { |
| 117 | + return '2.0.4'; |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * @inheritdoc |
| 122 | + */ |
| 123 | + public function getAliases() |
| 124 | + { |
| 125 | + return []; |
| 126 | + } |
| 127 | +} |
0 commit comments