test_batch_test.install
Same filename in other branches
File
-
core/
modules/ system/ tests/ modules/ test_batch_test/ test_batch_test.install
View source
<?php
/**
* @file
* Install hooks for test module.
*/
declare (strict_types=1);
use Drupal\entity_test\Entity\EntityTest;
/**
* Implements hook_install().
*/
function test_batch_test_install() : void {
$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
Title | Deprecated | Summary |
---|---|---|
test_batch_test_install | Implements hook_install(). | |
_test_batch_test_callback | Callback for batch operations. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.