protected function RelationFeedsProcessor::existingEntityId in Relation 7        
                          
                  
                        
File
 
   - relation_feeds/RelationFeedsProcessor.inc, line 341
 
  - Class definition of RelationFeedsProcessor.
 
  Class
  
  - RelationFeedsProcessor 
 
  - Creates relations from feed items.
 
Code
protected function existingEntityId(FeedsSource $source, FeedsParserResult $result) {
  if ($rid = parent::existingEntityId($source, $result)) {
    return $rid;
  }
  
  foreach ($this
    ->uniqueTargets($source, $result) as $target => $value) {
    switch ($target) {
      case 'rid':
        $rid = db_query("SELECT rid FROM {relation} WHERE rid = :rid", array(
          ':rid' => $value,
        ))
          ->fetchField();
        break;
      case 'feeds_source':
        if ($id = feeds_get_importer_id($this->config['bundle'])) {
          $rid = db_query("SELECT fs.feed_rid FROM {relation} r JOIN {feeds_source} fs ON r.rid = fs.feed_rid WHERE fs.id = :id AND fs.source = :source", array(
            ':id' => $id,
            ':source' => $value,
          ))
            ->fetchField();
        }
        break;
    }
    if ($rid) {
      
      return $rid;
    }
  }
  
  if ($this->config['unique_enpoints']) {
    try {
      $endpoints = $this
        ->mapEndpoints($source, $result);
    } catch (FeedsValidationException $f) {
      return 0;
    }
    $type = $this
      ->getTypeInfo();
    $relations = relation_relation_exists($endpoints, $this->config['bundle'], $type->directional);
    if ($relations) {
      return key($relations);
    }
  }
  return 0;
}