@@ -41,23 +41,21 @@ public function __construct(Data $directoryData)
41
41
public function upgrade (ModuleDataSetupInterface $ setup , ModuleContextInterface $ context )
42
42
{
43
43
if (version_compare ($ context ->getVersion (), '2.0.1 ' , '< ' )) {
44
- $ this ->addCroatia ($ setup );
44
+ $ this ->addCountryRegions ($ setup , $ this ->getDataForCroatia ());
45
+ }
46
+ if (version_compare ($ context ->getVersion (), '2.0.2 ' , '< ' )) {
47
+ $ this ->addCountryRegions ($ setup , $ this ->getDataForIndia ());
45
48
}
46
49
}
47
50
48
51
/**
49
- * Add Croatia and it's states to appropriate tables .
52
+ * Croatian states data .
50
53
*
51
- * @param ModuleDataSetupInterface $setup
52
- * @return void
54
+ * @return array
53
55
*/
54
- private function addCroatia ( $ setup )
56
+ private function getDataForCroatia ( )
55
57
{
56
- /**
57
- * Fill table directory/country_region
58
- * Fill table directory/country_region_name for en_US locale
59
- */
60
- $ data = [
58
+ return [
61
59
['HR ' , 'HR-01 ' , 'Zagrebačka županija ' ],
62
60
['HR ' , 'HR-02 ' , 'Krapinsko-zagorska županija ' ],
63
61
['HR ' , 'HR-03 ' , 'Sisačko-moslavačka županija ' ],
@@ -80,6 +78,68 @@ private function addCroatia($setup)
80
78
['HR ' , 'HR-20 ' , 'Međimurska županija ' ],
81
79
['HR ' , 'HR-21 ' , 'Grad Zagreb ' ]
82
80
];
81
+ }
82
+
83
+ /**
84
+ * Indian states data.
85
+ *
86
+ * @return array
87
+ */
88
+ private function getDataForIndia ()
89
+ {
90
+ return [
91
+ ['IN ' , 'AN ' , 'Andaman and Nicobar Islands ' ],
92
+ ['IN ' , 'AP ' , 'Andhra Pradesh ' ],
93
+ ['IN ' , 'AR ' , 'Arunachal Pradesh ' ],
94
+ ['IN ' , 'AS ' , 'Assam ' ],
95
+ ['IN ' , 'BR ' , 'Bihar ' ],
96
+ ['IN ' , 'CH ' , 'Chandigarh ' ],
97
+ ['IN ' , 'CT ' , 'Chhattisgarh ' ],
98
+ ['IN ' , 'DN ' , 'Dadra and Nagar Haveli ' ],
99
+ ['IN ' , 'DD ' , 'Daman and Diu ' ],
100
+ ['IN ' , 'DL ' , 'Delhi ' ],
101
+ ['IN ' , 'GA ' , 'Goa ' ],
102
+ ['IN ' , 'GJ ' , 'Gujarat ' ],
103
+ ['IN ' , 'HR ' , 'Haryana ' ],
104
+ ['IN ' , 'HP ' , 'Himachal Pradesh ' ],
105
+ ['IN ' , 'JK ' , 'Jammu and Kashmir ' ],
106
+ ['IN ' , 'JH ' , 'Jharkhand ' ],
107
+ ['IN ' , 'KA ' , 'Karnataka ' ],
108
+ ['IN ' , 'KL ' , 'Kerala ' ],
109
+ ['IN ' , 'LD ' , 'Lakshadweep ' ],
110
+ ['IN ' , 'MP ' , 'Madhya Pradesh ' ],
111
+ ['IN ' , 'MH ' , 'Maharashtra ' ],
112
+ ['IN ' , 'MN ' , 'Manipur ' ],
113
+ ['IN ' , 'ML ' , 'Meghalaya ' ],
114
+ ['IN ' , 'MZ ' , 'Mizoram ' ],
115
+ ['IN ' , 'NL ' , 'Nagaland ' ],
116
+ ['IN ' , 'OR ' , 'Odisha ' ],
117
+ ['IN ' , 'PY ' , 'Puducherry ' ],
118
+ ['IN ' , 'PB ' , 'Punjab ' ],
119
+ ['IN ' , 'RJ ' , 'Rajasthan ' ],
120
+ ['IN ' , 'SK ' , 'Sikkim ' ],
121
+ ['IN ' , 'TN ' , 'Tamil Nadu ' ],
122
+ ['IN ' , 'TG ' , 'Telangana ' ],
123
+ ['IN ' , 'TR ' , 'Tripura ' ],
124
+ ['IN ' , 'UP ' , 'Uttar Pradesh ' ],
125
+ ['IN ' , 'UT ' , 'Uttarakhand ' ],
126
+ ['IN ' , 'WB ' , 'West Bengal ' ]
127
+ ];
128
+ }
129
+
130
+ /**
131
+ * Add country regions data to appropriate tables.
132
+ *
133
+ * @param ModuleDataSetupInterface $setup
134
+ * @param array $data
135
+ * @return void
136
+ */
137
+ private function addCountryRegions (ModuleDataSetupInterface $ setup , array $ data )
138
+ {
139
+ /**
140
+ * Fill table directory/country_region
141
+ * Fill table directory/country_region_name for en_US locale
142
+ */
83
143
foreach ($ data as $ row ) {
84
144
$ bind = ['country_id ' => $ row [0 ], 'code ' => $ row [1 ], 'default_name ' => $ row [2 ]];
85
145
$ setup ->getConnection ()->insert ($ setup ->getTable ('directory_country_region ' ), $ bind );
0 commit comments