function social_content_get_last_id in Social Content 7
Get the last external id that was imported.
Parameters
object $social_content_type: The social content type object.
string $langcode: The language code string.
Return value
string|bool The latest external id, or NULL if nothing was found.
1 call to social_content_get_last_id()
- social_content_run_import in ./
social_content.module - Run an import for a particular social content type.
File
- ./
social_content.module, line 326 - Social Content module.
Code
function social_content_get_last_id($social_content_type, $langcode) {
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', $social_content_type['content_type'])
->propertyCondition('language', $langcode)
->propertyOrderBy('created', 'DESC')
->range(0, 1)
->execute();
if (!empty($result) && isset($result['node'])) {
$nodes = node_load_multiple(array_keys($result['node']));
$node = array_shift($nodes);
$field_name = current($social_content_type['external_id_field_mapping']);
$field = field_get_items('node', $node, $field_name, $langcode);
if ($field && isset($field[0]['value'])) {
return $field[0]['value'];
}
}
return NULL;
}