You are here

public static function FeedImport::processFeed in Feed Import 7

Same name and namespace in other branches
  1. 7.2 feed_import.inc.php \FeedImport::processFeed()

This function is choosing process function and executes it

Parameters

array $feed: Feed info array

1 call to FeedImport::processFeed()
feed_import_import_items in ./feed_import.module
Import feed and set report

File

./feed_import.inc.php, line 215
Feed import class for parsing and processing content

Class

FeedImport
@file Feed import class for parsing and processing content

Code

public static function processFeed(array $feed) {

  // Reset report
  self::$report = array(
    'rescheduled' => 0,
    'updated' => 0,
    'new' => 0,
    'total' => 0,
    'start' => time(),
    'time' => 0,
    'parse' => 0,
    'errors' => array(),
  );

  // Check if entity node/save/load functions exists
  if (!self::checkFunctions($feed['entity_info']['#entity'])) {
    return FALSE;
  }

  // Set error handler
  set_error_handler(array(
    __CLASS__,
    'errorHandler',
  ));
  $func = $feed['xpath']['#process_function'];
  $functions = self::processFunctions();
  if (!$func || !isset($functions[$func])) {

    // Get first function if there's no specified function
    $func = self::processFunctions();
    $func = reset($func);
  }
  else {
    $func = $functions[$func];
  }
  unset($functions);

  // Get property temp name to store hash value
  self::$tempHash = variable_get('feed_import_hash_property', self::$tempHash);

  // Reset generated hashes
  self::$generatedHashes = array();

  // Give import time (for large imports)
  set_time_limit(0);

  // Call process function to get processed items
  $items = call_user_func($func, $feed);

  // Parse report
  self::$report['parse'] = time();

  // Save items
  if (!empty($items)) {
    self::saveEntities($feed, $items);
  }

  // Set total time report
  self::$report['time'] = time() - self::$report['start'];
  self::$report['parse'] -= self::$report['start'];

  // Restore error handler
  restore_error_handler();
}