You are here

private function ContentDevelGenerate::generateContent in Devel 8.3

Same name and namespace in other branches
  1. 8 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()

Generate content when not in batch mode.

This method is used when the number of elements is under 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 401

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();
    $values['num_translations'] = 0;
    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();
        $options = [
          '@feedback' => drush_get_option('feedback', 1000),
          '@rate' => drush_get_option('feedback', 1000) * 60 / ($now - $start),
        ];
        drush_log(dt('Completed @feedback nodes (@rate nodes/min)', $options), 'ok');
        $start = $now;
      }
    }
  }
  $this
    ->setMessage($this
    ->formatPlural($values['num'], 'Created 1 node', 'Created @count nodes'));
  if ($values['num_translations'] > 0) {
    $this
      ->setMessage($this
      ->formatPlural($values['num_translations'], 'Created 1 node translation', 'Created @count node translations'));
  }
}