|
1 | 1 | # Drupal Batch Examples
|
| 2 | + |
| 3 | +Compatible with Drupal 10 and 11. |
| 4 | + |
| 5 | +This codebase contains a number of modules that show how to use the batch API |
| 6 | +in different ways. The modules have been split into different parts to show |
| 7 | +different parts of the batch API in action. |
| 8 | + |
| 9 | +Every module has a form that can be submitted to initiate the batch process. |
| 10 | + |
| 11 | +All modules have unit tests to test that the batch has run correctly. |
| 12 | + |
| 13 | +## Drupal Batch Examples |
| 14 | + |
| 15 | +A meta-module to provide a consistent navigation system for the other examples. |
| 16 | + |
| 17 | +Path: /drupal-batch-examples |
| 18 | + |
| 19 | +## Batch Form Example |
| 20 | + |
| 21 | +An example of running a batch in a self contained form. |
| 22 | + |
| 23 | +Path: `/drupal-batch-examples/batch-form-example` |
| 24 | + |
| 25 | +## Batch Class Example |
| 26 | + |
| 27 | +An example of running batch via a class. Includes Drush support. |
| 28 | + |
| 29 | +Path: `/drupal-batch-examples/batch-class-example` |
| 30 | + |
| 31 | +This module also shows how to use the batch API in Drush. The same batch process |
| 32 | +is run via the form and via the Drush command `drush batch_class_example:run`. |
| 33 | + |
| 34 | +## Batch Finish Example |
| 35 | + |
| 36 | +An example of using the finish property of the batch API. |
| 37 | + |
| 38 | +Path: `/drupal-batch-examples/batch-finish-example` |
| 39 | + |
| 40 | +## Batch Addition Example |
| 41 | + |
| 42 | +An example of adding a batch inside a running batch. |
| 43 | + |
| 44 | +Path: `/drupal-batch-examples/batch-addition-example` |
| 45 | + |
| 46 | +## Batch CSV Example |
| 47 | + |
| 48 | +An example of using the batch API to process a CSV file. |
| 49 | + |
| 50 | +This batch process will create nodes of the type "article", which comes with the |
| 51 | +standard install profile. In this case we are taking a two column CSV and using |
| 52 | +the first column for the title and the second column for the body content. |
| 53 | + |
| 54 | +Path: `/drupal-batch-examples/batch-csv-example` |
| 55 | + |
| 56 | +You can download the CSV needed for this form at the path |
| 57 | +`/drupal-batch-examples/batch-csv-example/generate-csv`, which is also linked to |
| 58 | +from the batch form itself. The CSV is generated from random data and so will |
| 59 | +be different every time you download it. |
0 commit comments