AddDataForIndia.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Directory\Setup\Patch\Data;
  7. use Magento\Directory\Setup\DataInstaller;
  8. use Magento\Framework\App\ResourceConnection;
  9. use Magento\Framework\Setup\ModuleDataSetupInterface;
  10. use Magento\Framework\Setup\Patch\DataPatchInterface;
  11. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  12. /**
  13. * Class AddDataForIndia
  14. * @package Magento\Directory\Setup\Patch\Data
  15. */
  16. class AddDataForIndia implements DataPatchInterface, PatchVersionInterface
  17. {
  18. /**
  19. * @var ModuleDataSetupInterface
  20. */
  21. private $moduleDataSetup;
  22. /**
  23. * @var \Magento\Directory\Setup\DataInstallerFactory
  24. */
  25. private $dataInstallerFactory;
  26. /**
  27. * AddDataForCroatia constructor.
  28. *
  29. * @param ModuleDataSetupInterface $moduleDataSetup
  30. * @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
  31. */
  32. public function __construct(
  33. ModuleDataSetupInterface $moduleDataSetup,
  34. \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
  35. ) {
  36. $this->moduleDataSetup = $moduleDataSetup;
  37. $this->dataInstallerFactory = $dataInstallerFactory;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function apply()
  43. {
  44. /** @var DataInstaller $dataInstaller */
  45. $dataInstaller = $this->dataInstallerFactory->create();
  46. $dataInstaller->addCountryRegions(
  47. $this->moduleDataSetup->getConnection(),
  48. $this->getDataForIndia()
  49. );
  50. }
  51. /**
  52. * Indian states data.
  53. *
  54. * @return array
  55. */
  56. private function getDataForIndia()
  57. {
  58. return [
  59. ['IN', 'AN', 'Andaman and Nicobar Islands'],
  60. ['IN', 'AP', 'Andhra Pradesh'],
  61. ['IN', 'AR', 'Arunachal Pradesh'],
  62. ['IN', 'AS', 'Assam'],
  63. ['IN', 'BR', 'Bihar'],
  64. ['IN', 'CH', 'Chandigarh'],
  65. ['IN', 'CT', 'Chhattisgarh'],
  66. ['IN', 'DN', 'Dadra and Nagar Haveli'],
  67. ['IN', 'DD', 'Daman and Diu'],
  68. ['IN', 'DL', 'Delhi'],
  69. ['IN', 'GA', 'Goa'],
  70. ['IN', 'GJ', 'Gujarat'],
  71. ['IN', 'HR', 'Haryana'],
  72. ['IN', 'HP', 'Himachal Pradesh'],
  73. ['IN', 'JK', 'Jammu and Kashmir'],
  74. ['IN', 'JH', 'Jharkhand'],
  75. ['IN', 'KA', 'Karnataka'],
  76. ['IN', 'KL', 'Kerala'],
  77. ['IN', 'LD', 'Lakshadweep'],
  78. ['IN', 'MP', 'Madhya Pradesh'],
  79. ['IN', 'MH', 'Maharashtra'],
  80. ['IN', 'MN', 'Manipur'],
  81. ['IN', 'ML', 'Meghalaya'],
  82. ['IN', 'MZ', 'Mizoram'],
  83. ['IN', 'NL', 'Nagaland'],
  84. ['IN', 'OR', 'Odisha'],
  85. ['IN', 'PY', 'Puducherry'],
  86. ['IN', 'PB', 'Punjab'],
  87. ['IN', 'RJ', 'Rajasthan'],
  88. ['IN', 'SK', 'Sikkim'],
  89. ['IN', 'TN', 'Tamil Nadu'],
  90. ['IN', 'TG', 'Telangana'],
  91. ['IN', 'TR', 'Tripura'],
  92. ['IN', 'UP', 'Uttar Pradesh'],
  93. ['IN', 'UT', 'Uttarakhand'],
  94. ['IN', 'WB', 'West Bengal']
  95. ];
  96. }
  97. /**
  98. * {@inheritdoc}
  99. */
  100. public static function getDependencies()
  101. {
  102. return [
  103. InitializeDirectoryData::class,
  104. ];
  105. }
  106. /**
  107. * {@inheritdoc}
  108. */
  109. public static function getVersion()
  110. {
  111. return '2.0.2';
  112. }
  113. /**
  114. * {@inheritdoc}
  115. */
  116. public function getAliases()
  117. {
  118. return [];
  119. }
  120. }