You are here

function devel_generate_content in Devel 7

Same name and namespace in other branches
  1. 5 devel_generate.inc \devel_generate_content()
  2. 6 devel_generate.inc \devel_generate_content()

The main API function for creating content.

See devel_generate_content_form() for the supported keys in $form_state['values']. Other modules may participate by form_alter() on that form and then handling their data during hook_node_insert() or in their own submit handler for the form.

Parameters

string $form_state:

Return value

void

2 calls to devel_generate_content()
devel_generate_content_form_submit in devel_generate/devel_generate.module
FormAPI submission to generate nodes.
drush_devel_generate_content in devel_generate/devel_generate.drush.inc
Command callback. Generate a number of nodes and comments.

File

devel_generate/devel_generate.inc, line 129

Code

function devel_generate_content($form_state) {
  if (!empty($form_state['values']['kill_content'])) {
    devel_generate_content_kill($form_state['values']);
  }
  if (count($form_state['values']['node_types'])) {

    // Generate nodes.
    devel_generate_content_pre_node($form_state['values']);
    $start = time();
    for ($i = 1; $i <= $form_state['values']['num_nodes']; $i++) {
      devel_generate_content_add_node($form_state['values']);
      if (function_exists('drush_log') && $i % drush_get_option('feedback', 1000) == 0) {
        $now = time();
        drush_log(dt('Completed !feedback nodes (!rate nodes/min)', array(
          '!feedback' => drush_get_option('feedback', 1000),
          '!rate' => drush_get_option('feedback', 1000) * 60 / ($now - $start),
        )), 'ok');
        $start = $now;
      }
    }
  }
  devel_generate_set_message(format_plural($form_state['values']['num_nodes'], '1 node created.', 'Finished creating @count nodes'));
}