protected function MediaDevelGenerate::generateBatchMedia in Devel 8.3
Same name and namespace in other branches
- 4.x devel_generate/src/Plugin/DevelGenerate/MediaDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\MediaDevelGenerate::generateBatchMedia()
Method for creating media when number of elements is greater than 50.
Parameters
array $values: The input values from the settings form.
1 call to MediaDevelGenerate::generateBatchMedia()
- MediaDevelGenerate::generateElements in devel_generate/
src/ Plugin/ DevelGenerate/ MediaDevelGenerate.php - Business logic relating with each DevelGenerate plugin.
File
- devel_generate/
src/ Plugin/ DevelGenerate/ MediaDevelGenerate.php, line 296
Class
- MediaDevelGenerate
- Provides a plugin that generates media entities.
Namespace
Drupal\devel_generate\Plugin\DevelGenerateCode
protected function generateBatchMedia(array $values) {
$operations = [];
// Setup the batch operations and save the variables.
$operations[] = [
'devel_generate_operation',
[
$this,
'batchPreGenerate',
$values,
],
];
// Add the kill operation.
if ($values['kill']) {
$operations[] = [
'devel_generate_operation',
[
$this,
'batchMediaKill',
$values,
],
];
}
// Add the operations to create the media.
for ($num = 0; $num < $values['num']; $num++) {
$operations[] = [
'devel_generate_operation',
[
$this,
'batchCreateMediaItem',
$values,
],
];
}
// Start the batch.
$batch = [
'title' => $this
->t('Generating media items'),
'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();
}
}