1.20.x node.module node_type_set_defaults($info = array())

Sets the default values for a node type.

The defaults are appropriate for a type defined through hook_node_info(), since 'custom' is TRUE for types defined in the user interface, and FALSE for types defined by modules. (The 'module' flag prevents types from being deleted through the user interface.) Also, the default for 'locked' is TRUE, which prevents users from changing the machine name of the type.

Parameters

$info: (optional) An object or array containing values to override the defaults. See hook_node_info() for details on what the array elements mean. Defaults to an empty array.

Return value

A node type object, with missing values in $info set to their defaults.:

File

modules/node/node.module, line 771
The core module that allows content to be submitted to the site.

Code

function node_type_set_defaults($info = array()) {
  $info = (array) $info;
  $new_type = $info + array(
    'type' => '',
    'name' => '',
    'base' => 'node_content',
    'module' => 'node',
    'node_preview' => BACKDROP_OPTIONAL,
    'description' => '',
    'help' => '',
    'modified' => FALSE,
    'disabled' => FALSE,
    'has_title' => TRUE,
    'title_label' => 'Title',
    'settings' => array(),
  );
  $new_type = (object) $new_type;

  // Mark if this content type exists already or not.
  if (empty($new_type->name)) {
    $new_type->is_new = TRUE;
  }

  // If the type has no title, set an empty label.
  if (!$new_type->has_title) {
    $new_type->title_label = '';
  }
  $new_type->orig_type = isset($info['type']) ? $info['type'] : '';

  // Populate module-provided defaults.
  $types = array(
    '_new' => $new_type
  );
  module_load_include('inc', 'node', 'node.types');
  foreach (module_implements('node_type_load') as $module) {
    $function = $module . '_node_type_load';
    $function($types);
  }
  $new_type = $types['_new'];

  return $new_type;
}