Skip to content

Commit c2262cd

Browse files
committed
fix: remap iso country db for TW
Change-Id: Ifa4de875e21b7d3254b319b5e610e3ead61606bd
1 parent a75b56d commit c2262cd

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

app/Http/Controllers/UserController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use App\Http\Controllers\OpenId\OpenIdController;
1717
use App\Http\Controllers\Traits\JsonResponses;
1818
use App\Http\Utils\CountryList;
19-
use App\Jobs\RevokeUserGrantsOnExplicitLogout;
2019
use App\libs\OAuth2\Strategies\LoginHintProcessStrategy;
2120
use App\ModelSerializers\SerializerRegistry;
2221
use Auth\Exceptions\AuthenticationException;

app/Http/Utils/CountryList.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,26 @@
1919
final class CountryList
2020
{
2121
private static function countrySort($a,$b) {
22-
$al = strtolower($a->getName());
23-
$bl = strtolower($b->getName());
22+
$al = strtolower($a['name']);
23+
$bl = strtolower($b['name']);
2424
if ($al == $bl) {
2525
return 0;
2626
}
2727
return ($al > $bl) ? +1 : -1;
2828
}
2929

30+
private static function countryMap2Dic($country) {
31+
return [
32+
'name' => $country->getAlpha2() == 'TW'? 'Taiwan' : $country->getName(),
33+
'alpha2' => $country->getAlpha2(),
34+
];
35+
}
36+
3037
public static function getCountries(){
3138
// init database
3239
$isoCodes = new IsoCodesFactory();
3340
$countries = $isoCodes->getCountries()->toArray();
41+
$countries = array_map( array('App\Http\Utils\CountryList','countryMap2Dic'), $countries);
3442
usort($countries, array('App\Http\Utils\CountryList','countrySort'));
3543
return $countries;
3644
}

resources/views/admin/edit-user.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
6969
let countries = [];
7070
@foreach($countries as $country)
71-
countries.push({value: "{!! $country->getAlpha2() !!}", text: "{!! $country->getName() !!}"});
71+
countries.push({value: "{!! $country['alpha2'] !!}", text: "{!! $country['name'] !!}"});
7272
@endforeach
7373
7474
let languages = [];

resources/views/auth/passwords/set.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
4444
let countries = [];
4545
@foreach($countries as $country)
46-
countries.push({ value: "{!! $country->getAlpha2() !!}", text: "{!! $country->getName() !!}" });
46+
countries.push({value: "{!! $country['alpha2'] !!}", text: "{!! $country['name'] !!}"});
4747
@endforeach
4848
4949
let config = {

resources/views/auth/register.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
4343
let countries = [];
4444
@foreach($countries as $country)
45-
countries.push({ value: "{!! $country->getAlpha2() !!}", text: "{!! $country->getName() !!}" });
45+
countries.push({value: "{!! $country['alpha2'] !!}", text: "{!! $country['name'] !!}"});
4646
@endforeach
4747
4848
let config = {

resources/views/profile.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
8787
let countries = [];
8888
@foreach($countries as $country)
89-
countries.push({value: "{!! $country->getAlpha2() !!}", text: "{!! $country->getName() !!}"});
89+
countries.push({value: "{!! $country['alpha2'] !!}", text: "{!! $country['name'] !!}"});
9090
@endforeach
9191
9292
let languages = [];

0 commit comments

Comments
 (0)