function cf_node_initialize_class in Common Functionality 7.2
Same name and namespace in other branches
- 7 modules/cf_node/cf_node.module \cf_node_initialize_class()
Create a node class object.
This is designed to be used for cf_node_create() or drupal_execute() functions. This generates the minimum fields required.
Parameters
string $node_type: The node type to initialize.
string $node_title: The note title to use.
string $node_body: (optional) The node body to use.
Return value
object A basic node object that can be safely passed to drupal_execute().
Related topics
File
- modules/
cf_node/ cf_node.module, line 47 - Common Functionality - Node module.
Code
function cf_node_initialize_class($node_type, $node_title, $node_body = '') {
$node_class = new stdClass();
if (cf_is_empty_or_non_string('node_type', $node_type, WATCHDOG_ERROR)) {
return $node_class;
}
if (cf_is_empty_or_non_string('node_title', $node_title, WATCHDOG_ERROR)) {
return $node_class;
}
if (!is_string($node_body)) {
$node_body = '';
}
// node_object_prepare requires the node.pages.inc be loaded to be called
module_load_include('inc', 'node', 'node.pages');
node_object_prepare($node_class);
$node_class->type = $node_type;
$node_class->title = $node_title;
$node_class->body = $node_body;
$node_class->active = TRUE;
return $node_class;
}