X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Flanguage%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FLanguageDomains.php;fp=web%2Fcore%2Fmodules%2Flanguage%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FLanguageDomains.php;h=2fcf7d75966e930680bf273e2469f294a28ea8b8;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/language/src/Plugin/migrate/process/LanguageDomains.php b/web/core/modules/language/src/Plugin/migrate/process/LanguageDomains.php new file mode 100644 index 000000000..2fcf7d759 --- /dev/null +++ b/web/core/modules/language/src/Plugin/migrate/process/LanguageDomains.php @@ -0,0 +1,44 @@ +getSourceProperty('domain_negotiation')) { + global $base_url; + + foreach ($value as $old_key => $old_value) { + if (empty($old_value['domain'])) { + // The default language domain might be empty. + // If it is, use the current domain. + $value[$old_key]['domain'] = parse_url($base_url, PHP_URL_HOST); + } + else { + // Ensure we have a protocol when checking for the hostname. + $domain = 'http://' . str_replace(['http://', 'https://'], '', $old_value['domain']); + // Only keep the host part of the domain. + $value[$old_key]['domain'] = parse_url($domain, PHP_URL_HOST); + } + } + } + + return parent::transform($value, $migrate_executable, $row, $destination_property); + } + +}