Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / system / tests / modules / update_test_postupdate / update_test_postupdate.post_update.php
1 <?php
2
3 /**
4  * @file
5  * Post update functions for test module.
6  */
7
8 /**
9  * First update.
10  */
11 function update_test_postupdate_post_update_first() {
12   $execution = \Drupal::state()->get('post_update_test_execution', []);
13   $execution[] = __FUNCTION__;
14   \Drupal::state()->set('post_update_test_execution', $execution);
15
16   return 'First update';
17 }
18
19 /**
20  * Second update.
21  */
22 function update_test_postupdate_post_update_second() {
23   $execution = \Drupal::state()->get('post_update_test_execution', []);
24   $execution[] = __FUNCTION__;
25   \Drupal::state()->set('post_update_test_execution', $execution);
26
27   return 'Second update';
28 }
29
30 /**
31  * Test1 update.
32  */
33 function update_test_postupdate_post_update_test1() {
34   $execution = \Drupal::state()->get('post_update_test_execution', []);
35   $execution[] = __FUNCTION__;
36   \Drupal::state()->set('post_update_test_execution', $execution);
37
38   return 'Test1 update';
39 }
40
41 /**
42  * Test0 update.
43  */
44 function update_test_postupdate_post_update_test0() {
45   $execution = \Drupal::state()->get('post_update_test_execution', []);
46   $execution[] = __FUNCTION__;
47   \Drupal::state()->set('post_update_test_execution', $execution);
48
49   return 'Test0 update';
50 }
51
52 /**
53  * Testing batch processing in post updates update.
54  */
55 function update_test_postupdate_post_update_test_batch(&$sandbox = NULL) {
56   if (!isset($sandbox['steps'])) {
57     $sandbox['current_step'] = 0;
58     $sandbox['steps'] = 3;
59   }
60
61   $sandbox['current_step']++;
62
63   $execution = \Drupal::state()->get('post_update_test_execution', []);
64   $execution[] = __FUNCTION__ . '-' . $sandbox['current_step'];
65   \Drupal::state()->set('post_update_test_execution', $execution);
66
67   $sandbox['#finished'] = $sandbox['current_step'] / $sandbox['steps'];
68   return 'Test post update batches';
69 }