You are here

private function ContentDevelGenerate::generateBatchContent in Devel 8.2

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

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

1 call to ContentDevelGenerate::generateBatchContent()
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 355

Class

ContentDevelGenerate
Provides a ContentDevelGenerate plugin.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

private function generateBatchContent($values) {

  // If it is drushBatch then this operation is already run in the
  // self::validateDrushParams().
  if (!$this->drushBatch) {

    // Setup the batch operations and save the variables.
    $operations[] = array(
      'devel_generate_operation',
      array(
        $this,
        'batchContentPreNode',
        $values,
      ),
    );
  }

  // Add the kill operation.
  if ($values['kill']) {
    $operations[] = array(
      'devel_generate_operation',
      array(
        $this,
        'batchContentKill',
        $values,
      ),
    );
  }

  // Add the operations to create the nodes.
  for ($num = 0; $num < $values['num']; $num++) {
    $operations[] = array(
      'devel_generate_operation',
      array(
        $this,
        'batchContentAddNode',
        $values,
      ),
    );
  }

  // Set the batch.
  $batch = array(
    'title' => $this
      ->t('Generating Content'),
    'operations' => $operations,
    'finished' => 'devel_generate_batch_finished',
    'file' => drupal_get_path('module', 'devel_generate') . '/devel_generate.batch.inc',
  );
  batch_set($batch);
  if ($this->drushBatch) {
    drush_backend_batch_process();
  }
}