Skip to content

Add regions for Belarus #33922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Directory\Setup\Patch\Data;

use Magento\Directory\Setup\DataInstaller;
use Magento\Directory\Setup\DataInstallerFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

/**
* Add Regions for Belarus.
*/
class AddDataForBelarus implements DataPatchInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;

/**
* @var DataInstallerFactory
*/
private $dataInstallerFactory;

/**
* @param ModuleDataSetupInterface $moduleDataSetup
* @param DataInstallerFactory $dataInstallerFactory
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
DataInstallerFactory $dataInstallerFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->dataInstallerFactory = $dataInstallerFactory;
}

/**
* @inheritdoc
*/
public function apply()
{
/** @var DataInstaller $dataInstaller */
$dataInstaller = $this->dataInstallerFactory->create();
$dataInstaller->addCountryRegions(
$this->moduleDataSetup->getConnection(),
$this->getDataForBelarus()
);
}

/**
* Belarus regions data.
*
* @return array
*/
private function getDataForBelarus(): array
{
return [
['BY', 'BY-BR', 'Bresckaja voblasć'],
['BY', 'BY-HO', 'Homieĺskaja voblasć'],
['BY', 'BY-HM', 'Horad Minsk'],
['BY', 'BY-HR', 'Hrodzienskaja voblasć'],
['BY', 'BY-MA', 'Mahilioŭskaja voblasć'],
['BY', 'BY-MI', 'Minskaja voblasć'],
['BY', 'BY-VI', 'Viciebskaja voblasć'],
];
}

/**
* @inheritdoc
*/
public static function getDependencies()
{
return [
InitializeDirectoryData::class,
];
}

/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testCountryHasRegions($countryId)
*
* @return array
*/
public function getCountryIdDataProvider():array
public function getCountryIdDataProvider(): array
{
return [
['countryId' => 'US'],
Expand Down Expand Up @@ -72,7 +72,8 @@ public function getCountryIdDataProvider():array
['countryId' => 'SE'],
['countryId' => 'GR'],
['countryId' => 'DK'],
['countryId' => 'AL']
['countryId' => 'AL'],
['countryId' => 'BY'],
];
}
}