You are here

protected function FeedsTermProcessor::existingItemId in Feeds 7

Same name and namespace in other branches
  1. 6 plugins/FeedsTermProcessor.inc \FeedsTermProcessor::existingItemId()

Get id of an existing feed item term if available.

Overrides FeedsProcessor::existingItemId

1 call to FeedsTermProcessor::existingItemId()
FeedsTermProcessor::process in plugins/FeedsTermProcessor.inc
Implements FeedsProcessor::process().

File

plugins/FeedsTermProcessor.inc, line 209
FeedsTermProcessor class.

Class

FeedsTermProcessor
Feeds processor plugin. Create taxonomy terms from feed items.

Code

protected function existingItemId(FeedsImportBatch $batch, FeedsSource $source) {

  // The only possible unique target is name.
  foreach ($this
    ->uniqueTargets($batch) as $target => $value) {
    if ($target == 'name') {
      $vocabulary = $this
        ->vocabulary();
      if ($tid = db_query("SELECT tid FROM {taxonomy_term_data} WHERE name = :name AND vid = :vid", array(
        ':name' => $value,
        ':vid' => $vocabulary->vid,
      ))
        ->fetchField()) {
        return $tid;
      }
    }
  }
  return 0;
}