Skip to content

Commit

Permalink
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions app/code/Magento/Directory/Setup/Patch/Data/AddDataForUruguay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?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 Uruguay States/Regions
*/
class AddDataForUruguay 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->getDataForUruguay()
);

return $this;
}

/**
* Uruguay states data.
*
* @return array
*/
private function getDataForUruguay(): array
{
return [
['UY', 'UY-AR', 'Artigas'],
['UY', 'UY-CA', 'Canelones'],
['UY', 'UY-CL', 'Cerro Largo'],
['UY', 'UY-CO', 'Colonia'],
['UY', 'UY-DU', 'Durazno'],
['UY', 'UY-FS', 'Flores'],
['UY', 'UY-FD', 'Florida'],
['UY', 'UY-LA', 'Lavalleja'],
['UY', 'UY-MA', 'Maldonado'],
['UY', 'UY-MO', 'Montevideo'],
['UY', 'UY-PA', 'Paysandu'],
['UY', 'UY-RN', 'Río Negro'],
['UY', 'UY-RV', 'Rivera'],
['UY', 'UY-RO', 'Rocha'],
['UY', 'UY-SA', 'Salto'],
['UY', 'UY-SJ', 'San José'],
['UY', 'UY-SO', 'Soriano'],
['UY', 'UY-TA', 'Tacuarembó'],
['UY', 'UY-TT', 'Treinta y Tres']
];
}

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

/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
}

0 comments on commit fa95e33

Please sign in to comment.