protected function FeedsEntityProcessor::existingEntityId in Feeds entity processor 7
Overrides FeedsProcessor::existingEntityId().
Tries to retrieve entity by ID if marked as unique target.
File
- src/
FeedsEntityProcessor.inc, line 299 - Contains FeedsEntityProcessor.
Class
- FeedsEntityProcessor
- Creates entities from feed items.
Code
protected function existingEntityId(FeedsSource $source, FeedsParserResult $result) {
$targets = $this
->uniqueTargets($source, $result);
$entity_info = $this
->entityInfo();
$entity_type = $this
->entityType();
if (!empty($entity_info['entity keys']['id']) && isset($targets[$entity_info['entity keys']['id']])) {
$entity_id = $targets[$entity_info['entity keys']['id']];
// Check if entity ID exists.
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $entity_type)
->entityCondition('entity_id', $entity_id);
$query_result = $query
->execute();
if (!empty($query_result[$entity_type])) {
return $entity_id;
}
}
// If no entity was found by now, try parent.
return parent::existingEntityId($source, $result);
}