You are here

public function FeedsExBase::parse in Feeds extensible parsers 7.2

Same name and namespace in other branches
  1. 7 src/FeedsExBase.inc \FeedsExBase::parse()

File

src/FeedsExBase.inc, line 181
Contains FeedsExBase.

Class

FeedsExBase
The Feeds extensible parser.

Code

public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
  $this
    ->loadLibrary();
  $this
    ->startErrorHandling();
  try {
    $result = $this
      ->delegateParsing($source, $fetcher_result);
  } catch (FeedsExEmptyException $e) {

    // The feed is empty.
    $this
      ->getMessenger()
      ->setMessage(t('The feed is empty.'), 'warning', FALSE);
    $result = new FeedsParserResult();
  } catch (Expcetion $exception) {

    // Do nothing. Store for later.
  }

  // Show some warnings.
  $errors = $this
    ->getErrors();
  if ($this->config['display_errors']) {
    $this
      ->printErrors($errors, WATCHDOG_DEBUG);
  }
  else {

    // Always print fatal errors.
    $this
      ->printErrors($errors);
  }

  // Log any fatal errors.
  $this
    ->logErrors($source, $errors);
  $this
    ->stopErrorHandling();
  if (isset($exception)) {
    throw $exception;
  }
  return $result;
}