You are here

protected function XmlParser::getErrors in Feeds extensible parsers 8

Returns the errors after parsing.

Return value

array A structured array array with keys:

  • message: The error message.
  • variables: The variables for the message.
  • severity: The severity of the message.

Overrides ParserBase::getErrors

See also

watchdog()

File

src/Feeds/Parser/XmlParser.php, line 376

Class

XmlParser
Defines a XML parser using XPath.

Namespace

Drupal\feeds_ex\Feeds\Parser

Code

protected function getErrors() {
  $return = [];
  foreach (libxml_get_errors() as $error) {

    // Translate error values.
    switch ($error->level) {
      case LIBXML_ERR_FATAL:
        $severity = RfcLogLevel::ERROR;
        break;
      case LIBXML_ERR_ERROR:
        $severity = RfcLogLevel::WARNING;
        break;
      default:
        $severity = RfcLogLevel::NOTICE;
        break;
    }
    $return[] = [
      'message' => '%error on line %num. Error code: %code',
      'variables' => [
        '%error' => trim($error->message),
        '%num' => $error->line,
        '%code' => $error->code,
      ],
      'severity' => $severity,
    ];
  }
  return $return;
}