-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade_status.api.php
58 lines (52 loc) · 1.49 KB
/
upgrade_status.api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* @file
* Hooks defined by Upgrade Status.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Extension\Extension;
/**
* @addtogroup hooks
* @{
*/
/**
* Alter the operations run on projects on the Upgrade Status UI.
*
* @param array $operations
* Batch operations array to be altered.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The submitted state of the upgrade status form.
*/
function hook_upgrade_status_operations_alter(array &$operations, FormStateInterface $form_state) {
// Duplicate each operation with another one that runs rector on the
// same extension.
if (!empty($form_state->getValue('run_rector'))) {
$keys = array_keys($operations);
foreach ($keys as $key) {
$operations[] = [
'update_rector_run_rector_batch',
[$operations[$key][1][0]],
];
}
}
}
/**
* Alter the build array for an upgrade status result group.
*
* @param array $build
* A render array with build results, including a 'title', 'description',
* 'errors', etc. keys.
* @param \Drupal\Core\Extension\Extension $extension
* Drupal extension object.
* @param string $group_key
* The key for the result group. One of 'rector', 'now', 'uncategorized',
* 'later' or 'ignore'.
*/
function hook_upgrade_status_result_alter(array &$build, Extension $extension, $group_key) {
if ($group_key == 'rector') {
$build['description']['#markup'] = t('Here is your patch...');
}
}
/**
* @} End of "addtogroup hooks".
*/