function social_content_save_post in Social Content 7
Save the current post.
Creates a entity_metadata_wrapper and sets the the title and external id. The wrapper is then passed to the "post_callback" function (defined in hook_social_content_info())
Parameters
objet $post: The post object
string $external_id: The external ID string
string $langcode: The language code to be used.
object $social_content_type: The social content type object.
array $settings: The settings array @see social_content_get_settings()
Return value
int|bool The created entity id.
See also
1 call to social_content_save_post()
- social_content_import_data in ./
social_content.module - Go through the posts and process each one.
File
- ./
social_content.module, line 374 - Social Content module.
Code
function social_content_save_post($post, $external_id, $langcode, $social_content_type, $settings) {
$path = $social_content_type['name'] . '/' . $external_id;
$values = array(
'type' => $social_content_type['content_type'],
'uid' => 1,
'status' => $settings['auto_publish'],
'promote' => 0,
'language' => $langcode,
'created' => time(),
'path' => array(
'alias' => $path,
),
);
$entity = entity_create('node', $values);
$wrapper = entity_metadata_wrapper('node', $entity);
// Set Title.
$wrapper->title
->set($social_content_type['title'] . ' : ' . $external_id);
// Set External ID field.
$extenal_id_field = current($social_content_type['external_id_field_mapping']);
$wrapper->{$extenal_id_field}
->set($external_id);
if (isset($social_content_type['post_callback'])) {
$function = $social_content_type['post_callback'];
if (function_exists($function)) {
$result = $function($wrapper, $post, $external_id, $settings);
if (!$result) {
return FALSE;
}
}
}
// Save the node.
$wrapper
->save();
return $wrapper
->getIdentifier();
}