From c3369ea432de73834649f07e9793307dde58f167 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 8 Feb 2020 16:48:32 +0100 Subject: [PATCH] implement localization installation --- Admin/Install/db.json | 34 +++++++++++++++++++++------------- Admin/Installer.php | 30 +++++++++++++++--------------- Models/LocalizationMapper.php | 3 +++ 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Admin/Install/db.json b/Admin/Install/db.json index b16212e..ea3c2de 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -22,7 +22,8 @@ "country_code2": { "name": "country_code2", "type": "VARCHAR(2)", - "null": false + "null": false, + "unique": true }, "country_code3": { "name": "country_code3", @@ -97,7 +98,8 @@ "language_639_2T": { "name": "language_639_2T", "type": "VARCHAR(2)", - "null": false + "null": false, + "unique": true }, "language_639_2B": { "name": "language_639_2B", @@ -134,21 +136,27 @@ "currency_symbol": { "name": "currency_symbol", "type": "VARCHAR(5)", - "null": false + "null": true }, "currency_code": { "name": "currency_code", "type": "VARCHAR(3)", - "null": false + "null": false, + "unique": true }, - "currency_decimals": { - "name": "currency_decimals", + "currency_decimal": { + "name": "currency_decimal", "type": "VARCHAR(10)", "null": false }, "currency_subunits": { "name": "currency_subunits", - "type": "TINYINT(3)", + "type": "INT(11)", + "null": true + }, + "currency_countries": { + "name": "currency_countries", + "type": "TEXT", "null": false } } @@ -165,19 +173,19 @@ }, "l11n_country": { "name": "l11n_country", - "type": "INT(11)", + "type": "VARCHAR(2)", "default": null, "null": true, "foreignTable": "country", - "foreignKey": "country_id" + "foreignKey": "country_code2" }, "l11n_language": { "name": "l11n_language", - "type": "INT(11)", + "type": "VARCHAR(2)", "default": null, "null": true, "foreignTable": "language", - "foreignKey": "language_id" + "foreignKey": "language_639_2T" }, "l11n_datetime": { "name": "l11n_datetime", @@ -187,11 +195,11 @@ }, "l11n_currency": { "name": "l11n_currency", - "type": "INT(11)", + "type": "VARCHAR(3)", "default": null, "null": true, "foreignTable": "currency", - "foreignKey": "currency_id" + "foreignKey": "currency_code" }, "l11n_number_thousand": { "name": "l11n_number_thousand", diff --git a/Admin/Installer.php b/Admin/Installer.php index 548ae40..9d933ff 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -75,10 +75,10 @@ final class Installer extends InstallerAbstract foreach ($countries as $country) { $query->values( - $country['country_name'], - $country['country_name'], - $country['country_code2'], - $country['country_code3'], + $country['country_name'] === null ? null : \trim($country['country_name']), + $country['country_name'] === null ? null : \trim($country['country_name']), + $country['country_code2'] === null ? null : \trim($country['country_code2']), + $country['country_code3'] === null ? null : \trim($country['country_code3']), $country['country_numeric'] ); } @@ -110,11 +110,11 @@ final class Installer extends InstallerAbstract foreach ($languages as $language) { $query->values( - $language['language_name'], - $language['language_native'], - $language['language_639_2T'], - $language['language_639_2B'], - $language['language_639_3'] + $language['language_name'] === null ? null : \trim($language['language_name']), + $language['language_native'] === null ? null : \trim($language['language_native']), + $language['language_639_2T'] === null ? null : \trim($language['language_639_2T']), + $language['language_639_2B'] === null ? null : \trim($language['language_639_2B']), + $language['language_639_3'] === null ? null : \trim($language['language_639_3']) ); } @@ -146,13 +146,13 @@ final class Installer extends InstallerAbstract foreach ($currencies as $currency) { $query->values( $currency['currency_id'], - $currency['currency_name'], - $currency['currency_code'], - $currency['currency_number'], - $currency['currency_symbol'], + $currency['currency_name'] === null ? null : \trim($currency['currency_name']), + $currency['currency_code'] === null ? null : \trim($currency['currency_code']), + $currency['currency_number'] === null ? null : \trim($currency['currency_number']), + $currency['currency_symbol'] === null ? null : \trim($currency['currency_symbol']), $currency['currency_subunits'], - $currency['currency_decimal'], - $currency['currency_countries'] + $currency['currency_decimal'] === null ? null : \trim($currency['currency_decimal']), + $currency['currency_countries'] === null ? null : \trim($currency['currency_countries']) ); } diff --git a/Models/LocalizationMapper.php b/Models/LocalizationMapper.php index 24013c0..3c1ae17 100644 --- a/Models/LocalizationMapper.php +++ b/Models/LocalizationMapper.php @@ -39,6 +39,9 @@ final class LocalizationMapper extends DataMapperAbstract */ protected static array $columns = [ 'l11n_id' => ['name' => 'l11n_id', 'type' => 'int', 'internal' => 'id'], + 'l11n_country' => ['name' => 'l11n_country', 'type' => 'string', 'internal' => 'country'], + 'l11n_language' => ['name' => 'l11n_language', 'type' => 'string', 'internal' => 'language'], + 'l11n_currency' => ['name' => 'l11n_currency', 'type' => 'string', 'internal' => 'currency'], 'l11n_number_thousand' => ['name' => 'l11n_number_thousand', 'type' => 'string', 'internal' => 'thousands'], 'l11n_number_decimal' => ['name' => 'l11n_number_decimal', 'type' => 'string', 'internal' => 'decimal'], 'l11n_angle' => ['name' => 'l11n_angle', 'type' => 'string', 'internal' => 'angle'],