function BatchTestCallbacks::callback5

Implements callback_batch_operation().

File

core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php, line 105

Class

BatchTestCallbacks
Batch callbacks for testing batches.

Namespace

Drupal\batch_test

Code

public function callback5($id, $sleep, &$context) : void {
    $batch_test_helper = new BatchTestHelper();
    // No-op, but ensure the batch takes a couple iterations.
    // Batch needs time to run for the test, so sleep a bit.
    usleep($sleep);
    // Track execution, and store some result for post-processing in the
    // 'finished' callback.
    $batch_test_helper->stack("op 5 id {$id}");
    $context['results'][5][] = $id;
    // This test is to test finished > 1
    $context['finished'] = 3.14;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.