You are here

private function ContentDevelGenerate::generateContent in Devel 8

Same name and namespace in other branches
  1. 8.3 devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate::generateContent()
  2. 8.2 devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate::generateContent()
  3. 4.x devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate::generateContent()

Method responsible for creating content when the number of elements is less than 50.

1 call to ContentDevelGenerate::generateContent()
ContentDevelGenerate::generateElements in devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php
Business logic relating with each DevelGenerate plugin

File

devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php, line 307

Class

ContentDevelGenerate
Provides a ContentDevelGenerate plugin.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

private function generateContent($values) {
  $values['node_types'] = array_filter($values['node_types']);
  if (!empty($values['kill']) && $values['node_types']) {
    $this
      ->contentKill($values);
  }
  if (!empty($values['node_types'])) {

    // Generate nodes.
    $this
      ->develGenerateContentPreNode($values);
    $start = time();
    for ($i = 1; $i <= $values['num']; $i++) {
      $this
        ->develGenerateContentAddNode($values);
      if ($this
        ->isDrush8() && 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;
      }
    }
  }
  $this
    ->setMessage($this
    ->formatPlural($values['num'], '1 node created.', 'Finished creating @count nodes'));
}