function social_content_import_data in Social Content 7
Go through the posts and process each one.
Checks whether the post already exists (if so it's skipped) Checks whether we've hit the limit.
Parameters
array $data: An array of posts, normally retrieved through the "data_callback".
object $social_content_type: The social content type object.
array $settings: The settings array @see social_content_get_settings()
settings $langcode: The language code being used.
Return value
int|bool The number of posts imported, or FALSE if it failed.
1 call to social_content_import_data()
- social_content_run_import in ./
social_content.module - Run an import for a particular social content type.
File
- ./
social_content.module, line 248 - Social Content module.
Code
function social_content_import_data($data, $social_content_type, $settings, $langcode = LANGUAGE_NONE) {
$count = 0;
foreach ($data as $post) {
$external_id_remote_field = key($social_content_type['external_id_field_mapping']);
if (!isset($post->{$external_id_remote_field})) {
watchdog('social_content', 'Unable to read external ID for !social_content_type', array(
'!social_content_type' => $social_content_type['title'],
), WATCHDOG_WARNING);
return FALSE;
}
$external_id = $post->{$external_id_remote_field};
if (social_content_post_exists($external_id, $social_content_type, $langcode)) {
break;
}
if ($settings['limit'] > 0 && $count > $settings['limit']) {
break;
}
if (social_content_save_post($post, $external_id, $langcode, $social_content_type, $settings)) {
$count++;
}
}
return $count;
}