test_batch_test.install in Drupal 8
Same filename and directory in other branches
Install hooks for test module.
File
core/modules/system/tests/modules/test_batch_test/test_batch_test.installView source
<?php
/**
* @file
* Install hooks for test module.
*/
use Drupal\entity_test\Entity\EntityTest;
/**
* Implements hook_install().
*/
function test_batch_test_install() {
$total = 2;
$operations = [];
for ($i = 1; $i <= $total; $i++) {
$operations[] = [
'_test_batch_test_callback',
[
$i,
],
];
}
$batch = [
'operations' => $operations,
];
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
batch_process();
}
/**
* Callback for batch operations.
*/
function _test_batch_test_callback($id) {
$entity = EntityTest::create([
'id' => $id,
]);
$entity
->save();
}
Functions
Name | Description |
---|---|
test_batch_test_install | Implements hook_install(). |
_test_batch_test_callback | Callback for batch operations. |