You are here

protected function FeedsXPathParserBase::errorStop in Feeds XPath Parser 7

Same name and namespace in other branches
  1. 6 FeedsXPathParserBase.inc \FeedsXPathParserBase::errorStop()

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 FeedsXPathParserBase::errorStop()
FeedsXPathParserBase::configFormValidate in ./FeedsXPathParserBase.inc
Overrides parent::sourceFormValidate().
FeedsXPathParserHTML::setup in ./FeedsXPathParserHTML.inc
Classes that use FeedsXPathParserBase must implement this.
FeedsXPathParserXML::setup in ./FeedsXPathParserXML.inc
Classes that use FeedsXPathParserBase must implement this.

File

./FeedsXPathParserBase.inc, line 572
Provides the base class for FeedsXPathParserHTML and FeedsXPathParserXML.

Class

FeedsXPathParserBase
Base class for the HTML and XML parsers.

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);
  if (function_exists('libxml_disable_entity_loader') && isset($this->loader)) {
    libxml_disable_entity_loader($this->loader);
    unset($this->loader);
  }
}