Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
API for easily creating batches.
Implementation info
Create a class that extends the EnumeratedBatchBase
or HighwaterBatchBase
. In here you'll need to build-out the ::processItem
method and a couple other methods involved in obtaining items, etc.
Invoke your batch class via form submit:
// Injected batch.factory service.
$batch = $this->batchFactory->getBatchFromClass(\Drupal\my_module\Batch\AwesomeBatch::class)
->setIds($this->gpraExport->getExportNids($group))
->getBatch();
batch_set($batch);
Or run your class via Drush:
// Injected batch.factory service.
$batchObj = $this->getBatchFactory()
->getBatchFromClass(\Drupal\my_module\Batch\AwesomeBatch::class);
$batch = $batchObj->getBatch();
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
// Process the batch.
drush_backend_batch_process();
Project information
- Module categories: Developer Tools
- 15 sites report using this module
- Created by kerasai on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.