AddDataForAustralia.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Directory\Setup\Patch\Data;
  8. use Magento\Directory\Setup\DataInstaller;
  9. use Magento\Framework\Setup\ModuleDataSetupInterface;
  10. use Magento\Framework\Setup\Patch\DataPatchInterface;
  11. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  12. /**
  13. * Adds Australian States
  14. */
  15. class AddDataForAustralia implements DataPatchInterface, PatchVersionInterface
  16. {
  17. /**
  18. * @var ModuleDataSetupInterface
  19. */
  20. private $moduleDataSetup;
  21. /**
  22. * @var \Magento\Directory\Setup\DataInstallerFactory
  23. */
  24. private $dataInstallerFactory;
  25. /**
  26. * @param ModuleDataSetupInterface $moduleDataSetup
  27. * @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
  28. */
  29. public function __construct(
  30. ModuleDataSetupInterface $moduleDataSetup,
  31. \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
  32. ) {
  33. $this->moduleDataSetup = $moduleDataSetup;
  34. $this->dataInstallerFactory = $dataInstallerFactory;
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function apply()
  40. {
  41. /** @var DataInstaller $dataInstaller */
  42. $dataInstaller = $this->dataInstallerFactory->create();
  43. $dataInstaller->addCountryRegions(
  44. $this->moduleDataSetup->getConnection(),
  45. $this->getDataForAustralia()
  46. );
  47. }
  48. /**
  49. * Australian states data.
  50. *
  51. * @return array
  52. */
  53. private function getDataForAustralia()
  54. {
  55. return [
  56. ['AU', 'ACT', 'Australian Capital Territory'],
  57. ['AU', 'NSW', 'New South Wales'],
  58. ['AU', 'VIC', 'Victoria'],
  59. ['AU', 'QLD', 'Queensland'],
  60. ['AU', 'SA', 'South Australia'],
  61. ['AU', 'TAS', 'Tasmania'],
  62. ['AU', 'WA', 'Western Australia'],
  63. ['AU', 'NT', 'Northern Territory']
  64. ];
  65. }
  66. /**
  67. * @inheritdoc
  68. */
  69. public static function getDependencies()
  70. {
  71. return [
  72. InitializeDirectoryData::class,
  73. AddDataForCroatia::class,
  74. AddDataForIndia::class,
  75. ];
  76. }
  77. /**
  78. * @inheritdoc
  79. */
  80. public static function getVersion()
  81. {
  82. return '2.0.3';
  83. }
  84. /**
  85. * @inheritdoc
  86. */
  87. public function getAliases()
  88. {
  89. return [];
  90. }
  91. }