XmlTrait.php in Migrate Plus 8.4
File
src/Plugin/migrate_plus/data_parser/XmlTrait.php
View source
<?php
namespace Drupal\migrate_plus\Plugin\migrate_plus\data_parser;
trait XmlTrait {
protected function registerNamespaces(\SimpleXMLElement $xml) {
if (isset($this->configuration['namespaces']) && is_array($this->configuration['namespaces'])) {
foreach ($this->configuration['namespaces'] as $prefix => $ns) {
$xml
->registerXPathNamespace($prefix, $ns);
}
}
}
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\nLine: @libxmlerrorline\nColumn: @libxmlerrorcolumn\nFile: @libxmlerrorfile", [
'@libxmlerrorcodename' => $error_code_name,
'@libxmlerrorcode' => $error->code,
'@libxmlerrormessage' => trim($error->message),
'@libxmlerrorline' => $error->line,
'@libxmlerrorcolumn' => $error->column,
'@libxmlerrorfile' => $error->file ? $error->file : NULL,
]);
}
}
Traits
Name |
Description |
XmlTrait |
Common functionality for XML data parsers. |