function BlockContentDevelGenerate::generateBatchContent

Generate content in batch mode.

This method is used when the number of elements is 50 or more.

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

File

devel_generate/src/Plugin/DevelGenerate/BlockContentDevelGenerate.php, line 248

Class

BlockContentDevelGenerate
Provides a BlockContentDevelGenerate plugin.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

private function generateBatchContent(array $values) : void {
    $operations = [];
    // Remove unselected block content types.
    $values['block_types'] = array_filter($values['block_types']);
    // If it is drushBatch then this operation is already run in the
    // self::validateDrushParams().
    // Add the kill operation.
    if ($values['kill']) {
        $operations[] = [
            'devel_generate_operation',
            [
                $this,
                'batchContentKill',
                $values,
            ],
        ];
    }
    // Add the operations to create the blocks.
    for ($num = 0; $num < $values['num']; ++$num) {
        $operations[] = [
            'devel_generate_operation',
            [
                $this,
                'batchContentAddBlock',
                $values,
            ],
        ];
    }
    // Set the batch.
    $batch = [
        'title' => $this->t('Generating Content'),
        'operations' => $operations,
        'finished' => 'devel_generate_batch_finished',
        'file' => $this->extensionPathResolver
            ->getPath('module', 'devel_generate') . '/devel_generate.batch.inc',
    ];
    batch_set($batch);
    if ($this->drushBatch) {
        drush_backend_batch_process();
    }
}