function cf_node_initialize_class in Common Functionality 7
Same name and namespace in other branches
- 7.2 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.
Why: See why from cf_node_create() function.
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.
array $function_history: (optional) An array of function names, ie: array('0' => 'my_function_name').
Return value
object A basic node object that can be safely passed to drupal_execute().
File
- modules/
cf_node/ cf_node.module, line 26
Code
function cf_node_initialize_class($node_type, $node_title, $node_body = '', array $function_history = array()) {
cf_error_append_history($function_history, __FUNCTION__);
$node_class = new stdClass();
if (cf_is_empty_or_non_string($function_history, 'node_type', $node_type, WATCHDOG_ERROR)) {
return $node_class;
}
if (cf_is_empty_or_non_string($function_history, '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;
}