protected function FarmAssetProcessor::existingEntityId in farmOS 7
Get id of an existing feed item asset if available.
File
- modules/
farm/ farm_asset/ includes/ feeds/ plugins/ FarmAssetProcessor.inc, line 263  - Class definition of FarmAssetProcessor.
 
Class
- FarmAssetProcessor
 - Creates farm assets 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 {farm_asset} WHERE id = :id", array(
          ':id' => $value,
        ))
          ->fetchField();
        break;
    }
    if (!empty($id)) {
      // Return with the first id found.
      return $id;
    }
  }
  return 0;
}