X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fmigrate_plus%2Fsrc%2FPlugin%2Fmigrate_plus%2Fdata_parser%2FXmlTrait.php;fp=web%2Fmodules%2Fcontrib%2Fmigrate_plus%2Fsrc%2FPlugin%2Fmigrate_plus%2Fdata_parser%2FXmlTrait.php;h=e1a8aafb0c67dbf94a23bdf6c12c827f9cda2a69;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/migrate_plus/src/Plugin/migrate_plus/data_parser/XmlTrait.php b/web/modules/contrib/migrate_plus/src/Plugin/migrate_plus/data_parser/XmlTrait.php new file mode 100644 index 000000000..e1a8aafb0 --- /dev/null +++ b/web/modules/contrib/migrate_plus/src/Plugin/migrate_plus/data_parser/XmlTrait.php @@ -0,0 +1,65 @@ +configuration['namespaces']) && is_array($this->configuration['namespaces'])) { + foreach ($this->configuration['namespaces'] as $prefix => $ns) { + $xml->registerXPathNamespace($prefix, $ns); + } + } + } + + /** + * Parses a LibXMLError to a error message string. + * + * @param \LibXMLError $error + * Error thrown by the XML. + * + * @return string + * Error message + */ + public static function parseLibXmlError(\LibXMLError $error) { + $error_code_name = 'Unknown Error'; + switch ($error->level) { + case LIBXML_ERR_WARNING: + $error_code_name = t('Warning'); + break; + + case LIBXML_ERR_ERROR: + $error_code_name = t('Error'); + break; + + case LIBXML_ERR_FATAL: + $error_code_name = t('Fatal Error'); + break; + } + + return t( + "@libxmlerrorcodename @libxmlerrorcode: @libxmlerrormessage\n" . + "Line: @libxmlerrorline\n" . + "Column: @libxmlerrorcolumn\n" . + "File: @libxmlerrorfile", + [ + '@libxmlerrorcodename' => $error_code_name, + '@libxmlerrorcode' => $error->code, + '@libxmlerrormessage' => trim($error->message), + '@libxmlerrorline' => $error->line, + '@libxmlerrorcolumn' => $error->column, + '@libxmlerrorfile' => (($error->file)) ? $error->file : NULL, + ] + ); + } + +}