Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1016 / 1016 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| LocationService | |
100.00% |
1016 / 1016 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1008 / 1008 |
|
100.00% |
1 / 1 |
1 | |||
| getCountryLabel | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getContinent | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getContinentLabel | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| isValidCountryCode | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Drupal\visitors\Service; |
| 4 | |
| 5 | use Drupal\Component\Render\MarkupInterface; |
| 6 | use Drupal\Core\StringTranslation\StringTranslationTrait; |
| 7 | use Drupal\Core\StringTranslation\TranslationInterface; |
| 8 | use Drupal\visitors\VisitorsLocationInterface; |
| 9 | |
| 10 | /** |
| 11 | * The location service. |
| 12 | */ |
| 13 | class LocationService implements VisitorsLocationInterface { |
| 14 | use StringTranslationTrait; |
| 15 | |
| 16 | /** |
| 17 | * List of countries. |
| 18 | * |
| 19 | * @var array |
| 20 | */ |
| 21 | protected $countries = []; |
| 22 | |
| 23 | /** |
| 24 | * List of continents. |
| 25 | * |
| 26 | * @var array |
| 27 | */ |
| 28 | protected $continents = []; |
| 29 | |
| 30 | /** |
| 31 | * Constructs a new LocationService object. |
| 32 | * |
| 33 | * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation |
| 34 | * The string translation service. |
| 35 | */ |
| 36 | public function __construct(TranslationInterface $string_translation) { |
| 37 | |
| 38 | $this->setStringTranslation($string_translation); |
| 39 | |
| 40 | $this->continents = [ |
| 41 | 'AF' => $this->t('Africa'), |
| 42 | 'AS' => $this->t('Asia'), |
| 43 | 'EU' => $this->t('Europe'), |
| 44 | 'NA' => $this->t('North America'), |
| 45 | 'OC' => $this->t('Oceania'), |
| 46 | 'SA' => $this->t('South America'), |
| 47 | 'AQ' => $this->t('Antarctica'), |
| 48 | ]; |
| 49 | |
| 50 | $this->countries = [ |
| 51 | 'AF' => [ |
| 52 | 'label' => $this->t('Afghanistan'), |
| 53 | 'continent' => 'AS', |
| 54 | ], |
| 55 | 'AX' => [ |
| 56 | 'label' => $this->t('Aland Islands'), |
| 57 | 'continent' => 'EU', |
| 58 | ], |
| 59 | 'AL' => [ |
| 60 | 'label' => $this->t('Albania'), |
| 61 | 'continent' => 'EU', |
| 62 | ], |
| 63 | 'DZ' => [ |
| 64 | 'label' => $this->t('Algeria'), |
| 65 | 'continent' => 'AF', |
| 66 | ], |
| 67 | 'AS' => [ |
| 68 | 'label' => $this->t('American Samoa'), |
| 69 | 'continent' => 'OC', |
| 70 | ], |
| 71 | 'AD' => [ |
| 72 | 'label' => $this->t('Andorra'), |
| 73 | 'continent' => 'EU', |
| 74 | ], |
| 75 | 'AO' => [ |
| 76 | 'label' => $this->t('Angola'), |
| 77 | 'continent' => 'AF', |
| 78 | ], |
| 79 | 'AI' => [ |
| 80 | 'label' => $this->t('Anguilla'), |
| 81 | 'continent' => 'NA', |
| 82 | ], |
| 83 | 'AQ' => [ |
| 84 | 'label' => $this->t('Antarctica'), |
| 85 | 'continent' => 'AQ', |
| 86 | ], |
| 87 | 'AG' => [ |
| 88 | 'label' => $this->t('Antigua and Barbuda'), |
| 89 | 'continent' => 'NA', |
| 90 | ], |
| 91 | 'AR' => [ |
| 92 | 'label' => $this->t('Argentina'), |
| 93 | 'continent' => 'SA', |
| 94 | ], |
| 95 | 'AM' => [ |
| 96 | 'label' => $this->t('Armenia'), |
| 97 | 'continent' => 'AS', |
| 98 | ], |
| 99 | 'AW' => [ |
| 100 | 'label' => $this->t('Aruba'), |
| 101 | 'continent' => 'SA', |
| 102 | ], |
| 103 | 'AU' => [ |
| 104 | 'label' => $this->t('Australia'), |
| 105 | 'continent' => 'OC', |
| 106 | ], |
| 107 | 'AT' => [ |
| 108 | 'label' => $this->t('Austria'), |
| 109 | 'continent' => 'EU', |
| 110 | ], |
| 111 | 'AZ' => [ |
| 112 | 'label' => $this->t('Azerbaijan'), |
| 113 | 'continent' => 'AS', |
| 114 | ], |
| 115 | 'BS' => [ |
| 116 | 'label' => $this->t('Bahamas'), |
| 117 | 'continent' => 'NA', |
| 118 | ], |
| 119 | 'BH' => [ |
| 120 | 'label' => $this->t('Bahrain'), |
| 121 | 'continent' => 'AS', |
| 122 | ], |
| 123 | 'BD' => [ |
| 124 | 'label' => $this->t('Bangladesh'), |
| 125 | 'continent' => 'AS', |
| 126 | ], |
| 127 | 'BB' => [ |
| 128 | 'label' => $this->t('Barbados'), |
| 129 | 'continent' => 'SA', |
| 130 | ], |
| 131 | 'BY' => [ |
| 132 | 'label' => $this->t('Belarus'), |
| 133 | 'continent' => 'EU', |
| 134 | ], |
| 135 | 'BE' => [ |
| 136 | 'label' => $this->t('Belgium'), |
| 137 | 'continent' => 'EU', |
| 138 | ], |
| 139 | 'BZ' => [ |
| 140 | 'label' => $this->t('Belize'), |
| 141 | 'continent' => 'NA"', |
| 142 | ], |
| 143 | 'BJ' => [ |
| 144 | 'label' => $this->t('Benin'), |
| 145 | 'continent' => 'AF', |
| 146 | ], |
| 147 | 'BM' => [ |
| 148 | 'label' => $this->t('Bermuda'), |
| 149 | 'continent' => 'NA', |
| 150 | ], |
| 151 | 'BT' => [ |
| 152 | 'label' => $this->t('Bhutan'), |
| 153 | 'continent' => 'AS', |
| 154 | ], |
| 155 | 'BO' => [ |
| 156 | 'label' => $this->t('Bolivia'), |
| 157 | 'continent' => 'SA', |
| 158 | ], |
| 159 | 'BQ' => [ |
| 160 | 'label' => $this->t('Bonaire, Sint Eustatius and Saba'), |
| 161 | 'continent' => 'SA', |
| 162 | ], |
| 163 | 'BA' => [ |
| 164 | 'label' => $this->t('Bosnia and Herzegovina'), |
| 165 | 'continent' => 'EU', |
| 166 | ], |
| 167 | 'BW' => [ |
| 168 | 'label' => $this->t('Botswana'), |
| 169 | 'continent' => 'AF', |
| 170 | ], |
| 171 | 'BV' => [ |
| 172 | 'label' => $this->t('Bouvet Island'), |
| 173 | 'continent' => 'SA', |
| 174 | ], |
| 175 | 'BR' => [ |
| 176 | 'label' => $this->t('Brazil'), |
| 177 | 'continent' => 'SA', |
| 178 | ], |
| 179 | 'IO' => [ |
| 180 | 'label' => $this->t('British Indian Ocean Territory'), |
| 181 | 'continent' => 'AF', |
| 182 | ], |
| 183 | 'BN' => [ |
| 184 | 'label' => $this->t('Brunei Darussalam'), |
| 185 | 'continent' => 'AS', |
| 186 | ], |
| 187 | 'BG' => [ |
| 188 | 'label' => $this->t('Bulgaria'), |
| 189 | 'continent' => 'EU', |
| 190 | ], |
| 191 | 'BF' => [ |
| 192 | 'label' => $this->t('Burkina Faso'), |
| 193 | 'continent' => 'AF', |
| 194 | ], |
| 195 | 'BI' => [ |
| 196 | 'label' => $this->t('Burundi'), |
| 197 | 'continent' => 'AF', |
| 198 | ], |
| 199 | 'CV' => [ |
| 200 | 'label' => $this->t('Cabo Verde'), |
| 201 | 'continent' => 'AF', |
| 202 | ], |
| 203 | 'KH' => [ |
| 204 | 'label' => $this->t('Cambodia'), |
| 205 | 'continent' => 'AS', |
| 206 | ], |
| 207 | 'CM' => [ |
| 208 | 'label' => $this->t('Cameroon'), |
| 209 | 'continent' => 'AF', |
| 210 | ], |
| 211 | 'CA' => [ |
| 212 | 'label' => $this->t('Canada'), |
| 213 | 'continent' => 'NA', |
| 214 | ], |
| 215 | 'KY' => [ |
| 216 | 'label' => $this->t('Cayman Islands'), |
| 217 | 'continent' => 'NA', |
| 218 | ], |
| 219 | 'CF' => [ |
| 220 | 'label' => $this->t('Central African Republic'), |
| 221 | 'continent' => 'AF', |
| 222 | ], |
| 223 | 'TD' => [ |
| 224 | 'label' => $this->t('Chad'), |
| 225 | 'continent' => 'AF', |
| 226 | ], |
| 227 | 'CL' => [ |
| 228 | 'label' => $this->t('Chile'), |
| 229 | 'continent' => 'SA', |
| 230 | ], |
| 231 | 'CN' => [ |
| 232 | 'label' => $this->t('China'), |
| 233 | 'continent' => 'AS', |
| 234 | ], |
| 235 | 'CX' => [ |
| 236 | 'label' => $this->t('Christmas Island'), |
| 237 | 'continent' => 'OC', |
| 238 | ], |
| 239 | 'CC' => [ |
| 240 | 'label' => $this->t('Cocos (Keeling) Islands'), |
| 241 | 'continent' => 'OC', |
| 242 | ], |
| 243 | 'CO' => [ |
| 244 | 'label' => $this->t('Colombia'), |
| 245 | 'continent' => 'SA', |
| 246 | ], |
| 247 | 'KM' => [ |
| 248 | 'label' => $this->t('Comoros'), |
| 249 | 'continent' => 'AF', |
| 250 | ], |
| 251 | 'CG' => [ |
| 252 | 'label' => $this->t('Congo'), |
| 253 | 'continent' => 'AF', |
| 254 | ], |
| 255 | 'CD' => [ |
| 256 | 'label' => $this->t('Congo, Democratic Republic of the'), |
| 257 | 'continent' => 'AF', |
| 258 | ], |
| 259 | 'CK' => [ |
| 260 | 'label' => $this->t('Cook Islands'), |
| 261 | 'continent' => 'OC', |
| 262 | ], |
| 263 | 'CR' => [ |
| 264 | 'label' => $this->t('Costa Rica'), |
| 265 | 'continent' => 'NA', |
| 266 | ], |
| 267 | 'CI' => [ |
| 268 | 'label' => $this->t("Côte d'Ivoire"), |
| 269 | 'continent' => 'AF', |
| 270 | ], |
| 271 | 'HR' => [ |
| 272 | 'label' => $this->t('Croatia'), |
| 273 | 'continent' => 'EU', |
| 274 | ], |
| 275 | 'CU' => [ |
| 276 | 'label' => $this->t('Cuba'), |
| 277 | 'continent' => 'NA', |
| 278 | ], |
| 279 | 'CW' => [ |
| 280 | 'label' => $this->t('Curaçao'), |
| 281 | 'continent' => 'SA', |
| 282 | ], |
| 283 | 'CY' => [ |
| 284 | 'label' => $this->t('Cyprus'), |
| 285 | 'continent' => 'AS', |
| 286 | ], |
| 287 | 'CZ' => [ |
| 288 | 'label' => $this->t('Czechia'), |
| 289 | 'continent' => 'EU', |
| 290 | ], |
| 291 | 'DK' => [ |
| 292 | 'label' => $this->t('Denmark'), |
| 293 | 'continent' => 'EU', |
| 294 | ], |
| 295 | 'DJ' => [ |
| 296 | 'label' => $this->t('Djibouti'), |
| 297 | 'continent' => 'AF', |
| 298 | ], |
| 299 | 'DM' => [ |
| 300 | 'label' => $this->t('Dominica'), |
| 301 | 'continent' => 'SA', |
| 302 | ], |
| 303 | 'DO' => [ |
| 304 | 'label' => $this->t('Dominican Republic'), |
| 305 | 'continent' => 'NA', |
| 306 | ], |
| 307 | 'EC' => [ |
| 308 | 'label' => $this->t('Ecuador'), |
| 309 | 'continent' => 'SA', |
| 310 | ], |
| 311 | 'EG' => [ |
| 312 | 'label' => $this->t('Egypt'), |
| 313 | 'continent' => 'AF', |
| 314 | ], |
| 315 | 'SV' => [ |
| 316 | 'label' => $this->t('El Salvador'), |
| 317 | 'continent' => 'SA', |
| 318 | ], |
| 319 | 'GQ' => [ |
| 320 | 'label' => $this->t('Equatorial Guinea'), |
| 321 | 'continent' => 'AF', |
| 322 | ], |
| 323 | 'ER' => [ |
| 324 | 'label' => $this->t('Eritrea'), |
| 325 | 'continent' => 'AF', |
| 326 | ], |
| 327 | 'EE' => [ |
| 328 | 'label' => $this->t('Estonia'), |
| 329 | 'continent' => 'EU', |
| 330 | ], |
| 331 | 'SZ' => [ |
| 332 | 'label' => $this->t('Eswatini'), |
| 333 | 'continent' => 'AF', |
| 334 | ], |
| 335 | 'ET' => [ |
| 336 | 'label' => $this->t('Ethiopia'), |
| 337 | 'continent' => 'AF', |
| 338 | ], |
| 339 | 'FK' => [ |
| 340 | 'label' => $this->t('Falkland Islands (Malvinas)'), |
| 341 | 'continent' => 'SA', |
| 342 | ], |
| 343 | 'FO' => [ |
| 344 | 'label' => $this->t('Faroe Islands'), |
| 345 | 'continent' => 'EU', |
| 346 | ], |
| 347 | 'FJ' => [ |
| 348 | 'label' => $this->t('Fiji'), |
| 349 | 'continent' => 'OC', |
| 350 | ], |
| 351 | 'FI' => [ |
| 352 | 'label' => $this->t('Finland'), |
| 353 | 'continent' => 'EU', |
| 354 | ], |
| 355 | 'FR' => [ |
| 356 | 'label' => $this->t('France'), |
| 357 | 'continent' => 'EU', |
| 358 | ], |
| 359 | 'GF' => [ |
| 360 | 'label' => $this->t('French Guiana'), |
| 361 | 'continent' => 'SA', |
| 362 | ], |
| 363 | 'PF' => [ |
| 364 | 'label' => $this->t('French Polynesia'), |
| 365 | 'continent' => 'OC', |
| 366 | ], |
| 367 | 'TF' => [ |
| 368 | 'label' => $this->t('French Southern Territories'), |
| 369 | 'continent' => 'AF', |
| 370 | ], |
| 371 | 'GA' => [ |
| 372 | 'label' => $this->t('Gabon'), |
| 373 | 'continent' => 'AF', |
| 374 | ], |
| 375 | 'GM' => [ |
| 376 | 'label' => $this->t('Gambia'), |
| 377 | 'continent' => 'AF', |
| 378 | ], |
| 379 | 'GE' => [ |
| 380 | 'label' => $this->t('Georgia'), |
| 381 | 'continent' => 'AS', |
| 382 | ], |
| 383 | 'DE' => [ |
| 384 | 'label' => $this->t('Germany'), |
| 385 | 'continent' => 'EU', |
| 386 | ], |
| 387 | 'GH' => [ |
| 388 | 'label' => $this->t('Ghana'), |
| 389 | 'continent' => 'AF', |
| 390 | ], |
| 391 | 'GI' => [ |
| 392 | 'label' => $this->t('Gibraltar'), |
| 393 | 'continent' => 'EU', |
| 394 | ], |
| 395 | 'GR' => [ |
| 396 | 'label' => $this->t('Greece'), |
| 397 | 'continent' => 'EU', |
| 398 | ], |
| 399 | 'GL' => [ |
| 400 | 'label' => $this->t('Greenland'), |
| 401 | 'continent' => 'NA', |
| 402 | ], |
| 403 | 'GD' => [ |
| 404 | 'label' => $this->t('Grenada'), |
| 405 | 'continent' => 'SA', |
| 406 | ], |
| 407 | 'GP' => [ |
| 408 | 'label' => $this->t('Guadeloupe'), |
| 409 | 'continent' => 'SA', |
| 410 | ], |
| 411 | 'GU' => [ |
| 412 | 'label' => $this->t('Guam'), |
| 413 | 'continent' => 'OC', |
| 414 | ], |
| 415 | 'GT' => [ |
| 416 | 'label' => $this->t('Guatemala'), |
| 417 | 'continent' => 'NA', |
| 418 | ], |
| 419 | 'GG' => [ |
| 420 | 'label' => $this->t('Guernsey'), |
| 421 | 'continent' => 'EU', |
| 422 | ], |
| 423 | 'GN' => [ |
| 424 | 'label' => $this->t('Guinea'), |
| 425 | 'continent' => 'AF', |
| 426 | ], |
| 427 | 'GW' => [ |
| 428 | 'label' => $this->t('Guinea-Bissau'), |
| 429 | 'continent' => 'AF', |
| 430 | ], |
| 431 | 'GY' => [ |
| 432 | 'label' => $this->t('Guyana'), |
| 433 | 'continent' => 'SA', |
| 434 | ], |
| 435 | 'HT' => [ |
| 436 | 'label' => $this->t('Haiti'), |
| 437 | 'continent' => 'NA', |
| 438 | ], |
| 439 | 'HM' => [ |
| 440 | 'label' => $this->t('Heard Island and McDonald Islands'), |
| 441 | 'continent' => 'OC', |
| 442 | ], |
| 443 | 'VA' => [ |
| 444 | 'label' => $this->t('Holy See'), |
| 445 | 'continent' => 'EU', |
| 446 | ], |
| 447 | 'HN' => [ |
| 448 | 'label' => $this->t('Honduras'), |
| 449 | 'continent' => 'NA', |
| 450 | ], |
| 451 | 'HK' => [ |
| 452 | 'label' => $this->t('Hong Kong'), |
| 453 | 'continent' => 'AS', |
| 454 | ], |
| 455 | 'HU' => [ |
| 456 | 'label' => $this->t('Hungary'), |
| 457 | 'continent' => 'EU', |
| 458 | ], |
| 459 | 'IS' => [ |
| 460 | 'label' => $this->t('Iceland'), |
| 461 | 'continent' => 'EU', |
| 462 | ], |
| 463 | 'IN' => [ |
| 464 | 'label' => $this->t('India'), |
| 465 | 'continent' => 'AS', |
| 466 | ], |
| 467 | 'ID' => [ |
| 468 | 'label' => $this->t('Indonesia'), |
| 469 | 'continent' => 'AS', |
| 470 | ], |
| 471 | 'IR' => [ |
| 472 | 'label' => $this->t('Iran'), |
| 473 | 'continent' => 'AS', |
| 474 | ], |
| 475 | 'IQ' => [ |
| 476 | 'label' => $this->t('Iraq'), |
| 477 | 'continent' => 'AS', |
| 478 | ], |
| 479 | 'IE' => [ |
| 480 | 'label' => $this->t('Ireland'), |
| 481 | 'continent' => 'EU', |
| 482 | ], |
| 483 | 'IM' => [ |
| 484 | 'label' => $this->t('Isle of Man'), |
| 485 | 'continent' => 'EU', |
| 486 | ], |
| 487 | 'IL' => [ |
| 488 | 'label' => $this->t('Israel'), |
| 489 | 'continent' => 'AS', |
| 490 | ], |
| 491 | 'IT' => [ |
| 492 | 'label' => $this->t('Italy'), |
| 493 | 'continent' => 'EU', |
| 494 | ], |
| 495 | 'JM' => [ |
| 496 | 'label' => $this->t('Jamaica'), |
| 497 | 'continent' => 'NA', |
| 498 | ], |
| 499 | 'JP' => [ |
| 500 | 'label' => $this->t('Japan'), |
| 501 | 'continent' => 'AS', |
| 502 | ], |
| 503 | 'JE' => [ |
| 504 | 'label' => $this->t('Jersey'), |
| 505 | 'continent' => 'EU', |
| 506 | ], |
| 507 | 'JO' => [ |
| 508 | 'label' => $this->t('Jordan'), |
| 509 | 'continent' => 'AS', |
| 510 | ], |
| 511 | 'KZ' => [ |
| 512 | 'label' => $this->t('Kazakhstan'), |
| 513 | 'continent' => 'AS', |
| 514 | ], |
| 515 | 'KE' => [ |
| 516 | 'label' => $this->t('Kenya,KE,AF'), |
| 517 | 'continent' => 'AF', |
| 518 | ], |
| 519 | 'KI' => [ |
| 520 | 'label' => $this->t('Kiribati'), |
| 521 | 'continent' => 'OC', |
| 522 | ], |
| 523 | 'KP' => [ |
| 524 | 'label' => $this->t("Korea (Democratic People's Republic of)"), |
| 525 | 'continent' => 'AS', |
| 526 | ], |
| 527 | 'KR' => [ |
| 528 | 'label' => $this->t('Korea, Republic of'), |
| 529 | 'continent' => 'AS', |
| 530 | ], |
| 531 | 'KW' => [ |
| 532 | 'label' => $this->t('Kuwait'), |
| 533 | 'continent' => 'AS', |
| 534 | ], |
| 535 | 'KG' => [ |
| 536 | 'label' => $this->t('Kyrgyzstan'), |
| 537 | 'continent' => 'AS', |
| 538 | ], |
| 539 | 'LA' => [ |
| 540 | 'label' => $this->t("Lao People's Democratic Republic"), |
| 541 | 'continent' => 'SA', |
| 542 | ], |
| 543 | 'LV' => [ |
| 544 | 'label' => $this->t('Latvia'), |
| 545 | 'continent' => 'EU', |
| 546 | ], |
| 547 | 'LB' => [ |
| 548 | 'label' => $this->t('Lebanon'), |
| 549 | 'continent' => 'AS', |
| 550 | ], |
| 551 | 'LS' => [ |
| 552 | 'label' => $this->t('Lesotho'), |
| 553 | 'continent' => 'AF', |
| 554 | ], |
| 555 | 'LR' => [ |
| 556 | 'label' => $this->t('Liberia'), |
| 557 | 'continent' => 'AF', |
| 558 | ], |
| 559 | 'LY' => [ |
| 560 | 'label' => $this->t('Libya'), |
| 561 | 'continent' => 'AF', |
| 562 | ], |
| 563 | 'LI' => [ |
| 564 | 'label' => $this->t('Liechtenstein'), |
| 565 | 'continent' => 'EU', |
| 566 | ], |
| 567 | 'LT' => [ |
| 568 | 'label' => $this->t('Lithuania'), |
| 569 | 'continent' => 'EU', |
| 570 | ], |
| 571 | 'LU' => [ |
| 572 | 'label' => $this->t('Luxembourg'), |
| 573 | 'continent' => 'EU', |
| 574 | ], |
| 575 | 'MO' => [ |
| 576 | 'label' => $this->t('Macao'), |
| 577 | 'continent' => 'AS', |
| 578 | ], |
| 579 | 'MG' => [ |
| 580 | 'label' => $this->t('Madagascar'), |
| 581 | 'continent' => 'AF', |
| 582 | ], |
| 583 | 'MW' => [ |
| 584 | 'label' => $this->t('Malawi'), |
| 585 | 'continent' => 'AF', |
| 586 | ], |
| 587 | 'MY' => [ |
| 588 | 'label' => $this->t('Malaysia'), |
| 589 | 'continent' => 'AS', |
| 590 | ], |
| 591 | 'MV' => [ |
| 592 | 'label' => $this->t('Maldives'), |
| 593 | 'continent' => 'AS', |
| 594 | ], |
| 595 | 'ML' => [ |
| 596 | 'label' => $this->t('Mali'), |
| 597 | 'continent' => 'AF', |
| 598 | ], |
| 599 | 'MT' => [ |
| 600 | 'label' => $this->t('Malta'), |
| 601 | 'continent' => 'EU', |
| 602 | ], |
| 603 | 'MH' => [ |
| 604 | 'label' => $this->t('Marshall Islands'), |
| 605 | 'continent' => 'OC', |
| 606 | ], |
| 607 | 'MQ' => [ |
| 608 | 'label' => $this->t('Martinique'), |
| 609 | 'continent' => 'SA', |
| 610 | ], |
| 611 | 'MR' => [ |
| 612 | 'label' => $this->t('Mauritania'), |
| 613 | 'continent' => 'AF', |
| 614 | ], |
| 615 | 'MU' => [ |
| 616 | 'label' => $this->t('Mauritius'), |
| 617 | 'continent' => 'AF', |
| 618 | ], |
| 619 | 'YT' => [ |
| 620 | 'label' => $this->t('Mayotte'), |
| 621 | 'continent' => 'AF', |
| 622 | ], |
| 623 | 'MX' => [ |
| 624 | 'label' => $this->t('Mexico'), |
| 625 | 'continent' => 'NA', |
| 626 | ], |
| 627 | 'FM' => [ |
| 628 | 'label' => $this->t('Micronesia (Federated States of)'), |
| 629 | 'continent' => 'OC', |
| 630 | ], |
| 631 | 'MD' => [ |
| 632 | 'label' => $this->t('Moldova, Republic of'), |
| 633 | 'continent' => 'EU', |
| 634 | ], |
| 635 | 'MC' => [ |
| 636 | 'label' => $this->t('Monaco'), |
| 637 | 'continent' => 'EU', |
| 638 | ], |
| 639 | 'MN' => [ |
| 640 | 'label' => $this->t('Mongolia'), |
| 641 | 'continent' => 'AS', |
| 642 | ], |
| 643 | 'ME' => [ |
| 644 | 'label' => $this->t('Montenegro'), |
| 645 | 'continent' => 'EU', |
| 646 | ], |
| 647 | 'MS' => [ |
| 648 | 'label' => $this->t('Montserrat'), |
| 649 | 'continent' => 'SA', |
| 650 | ], |
| 651 | 'MA' => [ |
| 652 | 'label' => $this->t('Morocco'), |
| 653 | 'continent' => 'AF', |
| 654 | ], |
| 655 | 'MZ' => [ |
| 656 | 'label' => $this->t('Mozambique'), |
| 657 | 'continent' => 'AF', |
| 658 | ], |
| 659 | 'MM' => [ |
| 660 | 'label' => $this->t('Myanmar'), |
| 661 | 'continent' => 'AS', |
| 662 | ], |
| 663 | 'NA' => [ |
| 664 | 'label' => $this->t('Namibia'), |
| 665 | 'continent' => 'AF', |
| 666 | ], |
| 667 | 'NR' => [ |
| 668 | 'label' => $this->t('Nauru'), |
| 669 | 'continent' => 'OC', |
| 670 | ], |
| 671 | 'NP' => [ |
| 672 | 'label' => $this->t('Nepal'), |
| 673 | 'continent' => 'AS', |
| 674 | ], |
| 675 | 'NL' => [ |
| 676 | 'label' => $this->t('Netherlands'), |
| 677 | 'continent' => 'EU', |
| 678 | ], |
| 679 | 'NC' => [ |
| 680 | 'label' => $this->t('New Caledonia'), |
| 681 | 'continent' => 'OC', |
| 682 | ], |
| 683 | 'NZ' => [ |
| 684 | 'label' => $this->t('New Zealand'), |
| 685 | 'continent' => 'OC', |
| 686 | ], |
| 687 | 'NI' => [ |
| 688 | 'label' => $this->t('Nicaragua'), |
| 689 | 'continent' => 'NA', |
| 690 | ], |
| 691 | 'NE' => [ |
| 692 | 'label' => $this->t('Niger'), |
| 693 | 'continent' => 'AF', |
| 694 | ], |
| 695 | 'NG' => [ |
| 696 | 'label' => $this->t('Nigeria'), |
| 697 | 'continent' => 'AF', |
| 698 | ], |
| 699 | 'NU' => [ |
| 700 | 'label' => $this->t('Niue'), |
| 701 | 'continent' => 'OC', |
| 702 | ], |
| 703 | 'NF' => [ |
| 704 | 'label' => $this->t('Norfolk Island'), |
| 705 | 'continent' => 'OC', |
| 706 | ], |
| 707 | 'MK' => [ |
| 708 | 'label' => $this->t('North Macedonia'), |
| 709 | 'continent' => 'EU', |
| 710 | ], |
| 711 | 'MP' => [ |
| 712 | 'label' => $this->t('Northern Mariana Islands'), |
| 713 | 'continent' => 'OC', |
| 714 | ], |
| 715 | 'NO' => [ |
| 716 | 'label' => $this->t('Norway'), |
| 717 | 'continent' => 'EU', |
| 718 | ], |
| 719 | 'OM' => [ |
| 720 | 'label' => $this->t('Oman'), |
| 721 | 'continent' => 'AS', |
| 722 | ], |
| 723 | 'PK' => [ |
| 724 | 'label' => $this->t('Pakistan'), |
| 725 | 'continent' => 'AS', |
| 726 | ], |
| 727 | 'PW' => [ |
| 728 | 'label' => $this->t('Palau'), |
| 729 | 'continent' => 'OC', |
| 730 | ], |
| 731 | 'PS' => [ |
| 732 | 'label' => $this->t('Palestine'), |
| 733 | 'continent' => 'AS', |
| 734 | ], |
| 735 | 'PA' => [ |
| 736 | 'label' => $this->t('Panama'), |
| 737 | 'continent' => 'NA', |
| 738 | ], |
| 739 | 'PG' => [ |
| 740 | 'label' => $this->t('Papua New Guinea'), |
| 741 | 'continent' => 'OC', |
| 742 | ], |
| 743 | 'PY' => [ |
| 744 | 'label' => $this->t('Paraguay'), |
| 745 | 'continent' => 'SA', |
| 746 | ], |
| 747 | 'PE' => [ |
| 748 | 'label' => $this->t('Peru'), |
| 749 | 'continent' => 'SA', |
| 750 | ], |
| 751 | 'PH' => [ |
| 752 | 'label' => $this->t('Philippines'), |
| 753 | 'continent' => 'AS', |
| 754 | ], |
| 755 | 'PN' => [ |
| 756 | 'label' => $this->t('Pitcairn'), |
| 757 | 'continent' => 'OC', |
| 758 | ], |
| 759 | 'PL' => [ |
| 760 | 'label' => $this->t('Poland'), |
| 761 | 'continent' => 'EU', |
| 762 | ], |
| 763 | 'PT' => [ |
| 764 | 'label' => $this->t('Portugal'), |
| 765 | 'continent' => 'EU', |
| 766 | ], |
| 767 | 'PR' => [ |
| 768 | 'label' => $this->t('Puerto Rico'), |
| 769 | 'continent' => 'NA', |
| 770 | ], |
| 771 | 'QA' => [ |
| 772 | 'label' => $this->t('Qatar'), |
| 773 | 'continent' => 'AS', |
| 774 | ], |
| 775 | 'RE' => [ |
| 776 | 'label' => $this->t('Réunion'), |
| 777 | 'continent' => 'AF', |
| 778 | ], |
| 779 | 'RO' => [ |
| 780 | 'label' => $this->t('Romania'), |
| 781 | 'continent' => 'EU', |
| 782 | ], |
| 783 | 'RU' => [ |
| 784 | 'label' => $this->t('Russia'), |
| 785 | 'continent' => 'EU', |
| 786 | ], |
| 787 | 'RW' => [ |
| 788 | 'label' => $this->t('Rwanda'), |
| 789 | 'continent' => 'AF', |
| 790 | ], |
| 791 | 'BL' => [ |
| 792 | 'label' => $this->t('Saint Barthélemy'), |
| 793 | 'continent' => 'SA', |
| 794 | ], |
| 795 | 'SH' => [ |
| 796 | 'label' => $this->t('Saint Helena, Ascension and Tristan da Cunha'), |
| 797 | 'continent' => 'AF', |
| 798 | ], |
| 799 | 'KN' => [ |
| 800 | 'label' => $this->t('Saint Kitts and Nevis'), |
| 801 | 'continent' => 'SA', |
| 802 | ], |
| 803 | 'LC' => [ |
| 804 | 'label' => $this->t('Saint Lucia'), |
| 805 | 'continent' => 'SA', |
| 806 | ], |
| 807 | 'MF' => [ |
| 808 | 'label' => $this->t('Saint Martin (French part)'), |
| 809 | 'continent' => 'SA', |
| 810 | ], |
| 811 | 'PM' => [ |
| 812 | 'label' => $this->t('Saint Pierre and Miquelon'), |
| 813 | 'continent' => 'NA', |
| 814 | ], |
| 815 | 'VC' => [ |
| 816 | 'label' => $this->t('Saint Vincent and the Grenadines'), |
| 817 | 'continent' => 'SA', |
| 818 | ], |
| 819 | 'WS' => [ |
| 820 | 'label' => $this->t('Samoa'), |
| 821 | 'continent' => 'OC', |
| 822 | ], |
| 823 | 'SM' => [ |
| 824 | 'label' => $this->t('San Marino'), |
| 825 | 'continent' => 'EU', |
| 826 | ], |
| 827 | 'ST' => [ |
| 828 | 'label' => $this->t('Sao Tome and Principe'), |
| 829 | 'continent' => 'AF', |
| 830 | ], |
| 831 | 'SA' => [ |
| 832 | 'label' => $this->t('Saudi Arabia'), |
| 833 | 'continent' => 'AS', |
| 834 | ], |
| 835 | 'SN' => [ |
| 836 | 'label' => $this->t('Senegal'), |
| 837 | 'continent' => 'AF', |
| 838 | ], |
| 839 | 'RS' => [ |
| 840 | 'label' => $this->t('Serbia'), |
| 841 | 'continent' => 'EU', |
| 842 | ], |
| 843 | 'SC' => [ |
| 844 | 'label' => $this->t('Seychelles'), |
| 845 | 'continent' => 'AF', |
| 846 | ], |
| 847 | 'SL' => [ |
| 848 | 'label' => $this->t('Sierra Leone'), |
| 849 | 'continent' => 'AF', |
| 850 | ], |
| 851 | 'SG' => [ |
| 852 | 'label' => $this->t('Singapore'), |
| 853 | 'continent' => 'AS', |
| 854 | ], |
| 855 | 'SX' => [ |
| 856 | 'label' => $this->t('Sint Maarten (Dutch part)'), |
| 857 | 'continent' => 'SA', |
| 858 | ], |
| 859 | 'SK' => [ |
| 860 | 'label' => $this->t('Slovakia'), |
| 861 | 'continent' => 'EU', |
| 862 | ], |
| 863 | 'SI' => [ |
| 864 | 'label' => $this->t('Slovenia'), |
| 865 | 'continent' => 'EU', |
| 866 | ], |
| 867 | 'SB' => [ |
| 868 | 'label' => $this->t('Solomon Islands'), |
| 869 | 'continent' => 'OC', |
| 870 | ], |
| 871 | 'SO' => [ |
| 872 | 'label' => $this->t('Somalia'), |
| 873 | 'continent' => 'AF', |
| 874 | ], |
| 875 | 'ZA' => [ |
| 876 | 'label' => $this->t('South Africa'), |
| 877 | 'continent' => 'AF', |
| 878 | ], |
| 879 | 'GS' => [ |
| 880 | 'label' => $this->t('South Georgia and the South Sandwich Islands'), |
| 881 | 'continent' => 'SA', |
| 882 | ], |
| 883 | 'SS' => [ |
| 884 | 'label' => $this->t('South Sudan'), |
| 885 | 'continent' => 'AF', |
| 886 | ], |
| 887 | 'ES' => [ |
| 888 | 'label' => $this->t('Spain'), |
| 889 | 'continent' => 'EU', |
| 890 | ], |
| 891 | 'LK' => [ |
| 892 | 'label' => $this->t('Sri Lanka'), |
| 893 | 'continent' => 'AS', |
| 894 | ], |
| 895 | 'SD' => [ |
| 896 | 'label' => $this->t('Sudan'), |
| 897 | 'continent' => 'AF', |
| 898 | ], |
| 899 | 'SR' => [ |
| 900 | 'label' => $this->t('Suriname'), |
| 901 | 'continent' => 'SA', |
| 902 | ], |
| 903 | 'SJ' => [ |
| 904 | 'label' => $this->t('Svalbard and Jan Mayen'), |
| 905 | 'continent' => 'EU', |
| 906 | ], |
| 907 | 'SE' => [ |
| 908 | 'label' => $this->t('Sweden'), |
| 909 | 'continent' => 'EU', |
| 910 | ], |
| 911 | 'CH' => [ |
| 912 | 'label' => $this->t('Switzerland'), |
| 913 | 'continent' => 'EU', |
| 914 | ], |
| 915 | 'SY' => [ |
| 916 | 'label' => $this->t('Syria'), |
| 917 | 'continent' => 'AS', |
| 918 | ], |
| 919 | 'TW' => [ |
| 920 | 'label' => $this->t('Taiwan'), |
| 921 | 'continent' => 'AS', |
| 922 | ], |
| 923 | 'TJ' => [ |
| 924 | 'label' => $this->t('Tajikistan'), |
| 925 | 'continent' => 'AS', |
| 926 | ], |
| 927 | 'TZ' => [ |
| 928 | 'label' => $this->t('Tanzania'), |
| 929 | 'continent' => 'AF', |
| 930 | ], |
| 931 | 'TH' => [ |
| 932 | 'label' => $this->t('Thailand'), |
| 933 | 'continent' => 'AS', |
| 934 | ], |
| 935 | 'TL' => [ |
| 936 | 'label' => $this->t('Timor-Leste'), |
| 937 | 'continent' => 'AS', |
| 938 | ], |
| 939 | 'TG' => [ |
| 940 | 'label' => $this->t('Togo'), |
| 941 | 'continent' => 'AF', |
| 942 | ], |
| 943 | 'TK' => [ |
| 944 | 'label' => $this->t('Tokelau'), |
| 945 | 'continent' => 'OC', |
| 946 | ], |
| 947 | 'TO' => [ |
| 948 | 'label' => $this->t('Tonga'), |
| 949 | 'continent' => 'OC', |
| 950 | ], |
| 951 | 'TT' => [ |
| 952 | 'label' => $this->t('Trinidad and Tobago'), |
| 953 | 'continent' => 'SA', |
| 954 | ], |
| 955 | 'TN' => [ |
| 956 | 'label' => $this->t('Tunisia'), |
| 957 | 'continent' => 'AF', |
| 958 | ], |
| 959 | 'TR' => [ |
| 960 | 'label' => $this->t('Turkey'), |
| 961 | 'continent' => 'AS', |
| 962 | ], |
| 963 | 'TM' => [ |
| 964 | 'label' => $this->t('Turkmenistan'), |
| 965 | 'continent' => 'AS', |
| 966 | ], |
| 967 | 'TC' => [ |
| 968 | 'label' => $this->t('Turks and Caicos Islands'), |
| 969 | 'continent' => 'NA', |
| 970 | ], |
| 971 | 'TV' => [ |
| 972 | 'label' => $this->t('Tuvalu'), |
| 973 | 'continent' => 'OC', |
| 974 | ], |
| 975 | 'UG' => [ |
| 976 | 'label' => $this->t('Uganda'), |
| 977 | 'continent' => 'AF', |
| 978 | ], |
| 979 | 'UA' => [ |
| 980 | 'label' => $this->t('Ukraine'), |
| 981 | 'continent' => 'EU', |
| 982 | ], |
| 983 | 'AE' => [ |
| 984 | 'label' => $this->t('United Arab Emirates'), |
| 985 | 'continent' => 'AS', |
| 986 | ], |
| 987 | 'GB' => [ |
| 988 | 'label' => $this->t('United Kingdom'), |
| 989 | 'continent' => 'EU', |
| 990 | ], |
| 991 | 'US' => [ |
| 992 | 'label' => $this->t('United States'), |
| 993 | 'continent' => 'NA', |
| 994 | ], |
| 995 | 'UM' => [ |
| 996 | 'label' => $this->t('United States Minor Outlying Islands'), |
| 997 | 'continent' => 'OC', |
| 998 | ], |
| 999 | 'UY' => [ |
| 1000 | 'label' => $this->t('Uruguay'), |
| 1001 | 'continent' => 'SA', |
| 1002 | ], |
| 1003 | 'UZ' => [ |
| 1004 | 'label' => $this->t('Uzbekistan'), |
| 1005 | 'continent' => 'AS', |
| 1006 | ], |
| 1007 | 'VU' => [ |
| 1008 | 'label' => $this->t('Vanuatu'), |
| 1009 | 'continent' => 'OC', |
| 1010 | ], |
| 1011 | 'VE' => [ |
| 1012 | 'label' => $this->t('Venezuela'), |
| 1013 | 'continent' => 'SA', |
| 1014 | ], |
| 1015 | 'VN' => [ |
| 1016 | 'label' => $this->t('Vietnam'), |
| 1017 | 'continent' => 'AS', |
| 1018 | ], |
| 1019 | 'VG' => [ |
| 1020 | 'label' => $this->t('Virgin Islands, British'), |
| 1021 | 'continent' => 'NA', |
| 1022 | ], |
| 1023 | 'VI' => [ |
| 1024 | 'label' => $this->t('Virgin Islands, US'), |
| 1025 | 'continent' => 'NA', |
| 1026 | ], |
| 1027 | 'WF' => [ |
| 1028 | 'label' => $this->t('Wallis and Futuna'), |
| 1029 | 'continent' => 'OC', |
| 1030 | ], |
| 1031 | 'EH' => [ |
| 1032 | 'label' => $this->t('Western Sahara'), |
| 1033 | 'continent' => 'AF', |
| 1034 | ], |
| 1035 | 'YE' => [ |
| 1036 | 'label' => $this->t('Yemen'), |
| 1037 | 'continent' => 'AS', |
| 1038 | ], |
| 1039 | 'ZM' => [ |
| 1040 | 'label' => $this->t('Zambia'), |
| 1041 | 'continent' => 'AF', |
| 1042 | ], |
| 1043 | 'ZW' => [ |
| 1044 | 'label' => $this->t('Zimbabwe'), |
| 1045 | 'continent' => 'AF', |
| 1046 | ], |
| 1047 | ]; |
| 1048 | } |
| 1049 | |
| 1050 | /** |
| 1051 | * {@inheritdoc} |
| 1052 | */ |
| 1053 | public function getCountryLabel($country_code): MarkupInterface { |
| 1054 | $country_code = strtoupper($country_code); |
| 1055 | return $this->countries[$country_code]['label'] ?? $this->t('Unknown'); |
| 1056 | } |
| 1057 | |
| 1058 | /** |
| 1059 | * {@inheritdoc} |
| 1060 | */ |
| 1061 | public function getContinent($country_code): string { |
| 1062 | $country_code = strtoupper($country_code); |
| 1063 | return $this->countries[$country_code]['continent'] ?? ''; |
| 1064 | } |
| 1065 | |
| 1066 | /** |
| 1067 | * {@inheritdoc} |
| 1068 | */ |
| 1069 | public function getContinentLabel($continent_code): MarkupInterface { |
| 1070 | $continent_code = strtoupper($continent_code); |
| 1071 | return $this->continents[$continent_code] ?? $this->t('Unknown'); |
| 1072 | } |
| 1073 | |
| 1074 | /** |
| 1075 | * {@inheritdoc} |
| 1076 | */ |
| 1077 | public function isValidCountryCode($country_code): bool { |
| 1078 | $country_code = strtoupper($country_code); |
| 1079 | return isset($this->countries[$country_code]); |
| 1080 | } |
| 1081 | |
| 1082 | } |