function ContentDevelGenerate::generateBatchContent
Same name in other branches
- 5.x devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate::generateBatchContent()
Generate content in batch mode.
This method is used when the number of elements is 50 or more.
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 436
Class
- ContentDevelGenerate
- Provides a ContentDevelGenerate plugin.
Namespace
Drupal\devel_generate\Plugin\DevelGenerateCode
private function generateBatchContent($values) {
// Remove unselected node types.
$values['node_types'] = array_filter($values['node_types']);
// 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[] = [
'devel_generate_operation',
[
$this,
'batchContentPreNode',
$values,
],
];
}
// Add the kill operation.
if ($values['kill']) {
$operations[] = [
'devel_generate_operation',
[
$this,
'batchContentKill',
$values,
],
];
}
// Add the operations to create the nodes.
for ($num = 0; $num < $values['num']; $num++) {
$operations[] = [
'devel_generate_operation',
[
$this,
'batchContentAddNode',
$values,
],
];
}
// Set the batch.
$batch = [
'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();
}
}