You are here

protected function ParserBase::errorStop in Feeds XPath Parser 8

Stops custom error handling.

Parameters

bool $use: The previous value of use_errors.

bool $print: (Optional) Whether to print errors to the screen. Defaults to TRUE.

3 calls to ParserBase::errorStop()
ParserBase::validateForm in lib/Drupal/feeds_xpathparser/ParserBase.php
Form validation handler.
XPathHTMLParser::setup in lib/Drupal/feeds_xpathparser/Plugin/feeds/Parser/XPathHTMLParser.php
Classes that use ParserBase must implement this.
XPathXMLParser::setup in lib/Drupal/feeds_xpathparser/Plugin/feeds/Parser/XPathXMLParser.php
Classes that use ParserBase must implement this.

File

lib/Drupal/feeds_xpathparser/ParserBase.php, line 601
Contains \Drupal\feeds_xpathparser\ParserBase.

Class

ParserBase
Base class for the HTML and XML parsers.

Namespace

Drupal\feeds_xpathparser

Code

protected function errorStop($use, $print = TRUE) {
  if ($print) {
    foreach (libxml_get_errors() as $error) {
      switch ($error->level) {
        case LIBXML_ERR_WARNING:
        case LIBXML_ERR_ERROR:
          $type = 'warning';
          break;
        case LIBXML_ERR_FATAL:
          $type = 'error';
          break;
      }
      $args = array(
        '%error' => trim($error->message),
        '%num' => $error->line,
        '%code' => $error->code,
      );
      $message = t('%error on line %num. Error code: %code', $args);
      drupal_set_message($message, $type, FALSE);
    }
  }
  libxml_clear_errors();
  libxml_use_internal_errors($use);
}