You are here

protected function LogProcessor::existingEntityId in Log entity 7

Get id of an existing feed item log if available.

File

includes/feeds/plugins/LogProcessor.inc, line 259
Class definition of LogProcessor.

Class

LogProcessor
Creates logs from feed items.

Code

protected function existingEntityId(FeedsSource $source, FeedsParserResult $result) {
  if ($id = parent::existingEntityId($source, $result)) {
    return $id;
  }

  // Iterate through all unique targets and test whether they do already
  // exist in the database.
  foreach ($this
    ->uniqueTargets($source, $result) as $target => $value) {
    switch ($target) {
      case 'id':
        $id = db_query("SELECT id FROM {log} WHERE id = :id", array(
          ':id' => $value,
        ))
          ->fetchField();
        break;
    }
    if (!empty($id)) {

      // Return with the first id found.
      return $id;
    }
  }
  return 0;
}