|
| 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 Regions for Belarus. |
| 17 | + */ |
| 18 | +class AddDataForBelarus 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->getDataForBelarus() |
| 52 | + ); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Belarus regions data. |
| 57 | + * |
| 58 | + * @return array |
| 59 | + */ |
| 60 | + private function getDataForBelarus(): array |
| 61 | + { |
| 62 | + return [ |
| 63 | + ['BY', 'BY-BR', 'Bresckaja voblasć'], |
| 64 | + ['BY', 'BY-HO', 'Homieĺskaja voblasć'], |
| 65 | + ['BY', 'BY-HM', 'Horad Minsk'], |
| 66 | + ['BY', 'BY-HR', 'Hrodzienskaja voblasć'], |
| 67 | + ['BY', 'BY-MA', 'Mahilioŭskaja voblasć'], |
| 68 | + ['BY', 'BY-MI', 'Minskaja voblasć'], |
| 69 | + ['BY', 'BY-VI', 'Viciebskaja voblasć'], |
| 70 | + ]; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * @inheritdoc |
| 75 | + */ |
| 76 | + public static function getDependencies() |
| 77 | + { |
| 78 | + return [ |
| 79 | + InitializeDirectoryData::class, |
| 80 | + ]; |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * @inheritdoc |
| 85 | + */ |
| 86 | + public function getAliases() |
| 87 | + { |
| 88 | + return []; |
| 89 | + } |
| 90 | +} |
0 commit comments