Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / update / tests / modules / update_test / update_test.module
1 <?php
2
3 /**
4  * @file
5  * Module for testing Update Manager functionality.
6  */
7
8 use Drupal\Core\Extension\Extension;
9
10 /**
11  * Implements hook_system_info_alter().
12  *
13  * Checks the 'update_test.settings:system_info' configuration and sees if we
14  * need to alter the system info for the given $file based on the setting. The
15  * setting is expected to be a nested associative array. If the key '#all' is
16  * defined, its subarray will include .info.yml keys and values for all modules
17  * and themes on the system. Otherwise, the settings array is keyed by the
18  * module or theme short name ($file->name) and the subarrays contain settings
19  * just for that module or theme.
20  */
21 function update_test_system_info_alter(&$info, Extension $file) {
22   $setting = \Drupal::config('update_test.settings')->get('system_info');
23   foreach (['#all', $file->getName()] as $id) {
24     if (!empty($setting[$id])) {
25       foreach ($setting[$id] as $key => $value) {
26         $info[$key] = $value;
27       }
28     }
29   }
30 }
31
32 /**
33  * Implements hook_update_status_alter().
34  *
35  * Checks the 'update_test.settings:update_status' configuration and sees if we
36  * need to alter the update status for the given project based on the setting.
37  * The setting is expected to be a nested associative array. If the key '#all'
38  * is defined, its subarray will include .info.yml keys and values for all modules
39  * and themes on the system. Otherwise, the settings array is keyed by the
40  * module or theme short name and the subarrays contain settings just for that
41  * module or theme.
42  */
43 function update_test_update_status_alter(&$projects) {
44   $setting = \Drupal::config('update_test.settings')->get('update_status');
45   if (!empty($setting)) {
46     foreach ($projects as $project_name => &$project) {
47       foreach (['#all', $project_name] as $id) {
48         if (!empty($setting[$id])) {
49           foreach ($setting[$id] as $key => $value) {
50             $project[$key] = $value;
51           }
52         }
53       }
54     }
55   }
56 }
57
58 /**
59  * Implements hook_filetransfer_info().
60  */
61 function update_test_filetransfer_info() {
62   // Define a test file transfer method, to ensure that there will always be at
63   // least one method available in the user interface (regardless of the
64   // environment in which the update manager tests are run).
65   return [
66     'system_test' => [
67       'title' => t('Update Test FileTransfer'),
68       'class' => 'Drupal\update_test\TestFileTransferWithSettingsForm',
69       'weight' => -20,
70     ],
71   ];
72 }