protected function InstagramFeedsPluginsNodeProcessor::existingEntityId in Instagram Feeds 7
Retrieve the target entity's existing id if available. Otherwise return 0.
Parameters
FeedsSource $source: The source information about this import.
FeedsParserResult $result: A FeedsParserResult object.
Return value
int The serial id of an entity if found, 0 otherwise.
1 call to InstagramFeedsPluginsNodeProcessor::existingEntityId()
- InstagramFeedsPluginsNodeProcessor::process in modules/
instagram_feeds_plugins/ plugins/ feeds/ InstagramFeedsPluginsNodeProcessor.inc - Process the result of the parsing stage.
File
- modules/
instagram_feeds_plugins/ plugins/ feeds/ InstagramFeedsPluginsNodeProcessor.inc, line 26 - Class definition of InstagramFeedsPluginsNodeProcessor.
Class
- InstagramFeedsPluginsNodeProcessor
- Creates nodes from feed items.
Code
protected function existingEntityId(FeedsSource $source, FeedsParserResult $result) {
$query = db_select('feeds_item')
->fields('feeds_item', array(
'entity_id',
))
->condition('entity_type', $this
->entityType())
->condition('id', $source->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 'url':
$entity_id = $query
->condition('url', $value)
->execute()
->fetchField();
break;
case 'guid':
$entity_id = $query
->condition('guid', $value)
->execute()
->fetchField();
break;
}
if (isset($entity_id)) {
// Return with the content id found.
return $entity_id;
}
}
return 0;
}