update_test.module in Zircon Profile 8
Same filename and directory in other branches
Module for testing Update Manager functionality.
File
core/modules/update/tests/modules/update_test/update_test.moduleView source
<?php
use Drupal\Core\Extension\Extension;
/**
* @file
* Module for testing Update Manager functionality.
*/
/**
* Implements hook_system_info_alter().
*
* Checks the 'update_test.settings:system_info' configuration and sees if we
* need to alter the system info for the given $file based on the setting. The
* setting is expected to be a nested associative array. If the key '#all' is
* defined, its subarray will include .info.yml keys and values for all modules
* and themes on the system. Otherwise, the settings array is keyed by the
* module or theme short name ($file->name) and the subarrays contain settings
* just for that module or theme.
*/
function update_test_system_info_alter(&$info, Extension $file) {
$setting = \Drupal::config('update_test.settings')
->get('system_info');
foreach (array(
'#all',
$file
->getName(),
) as $id) {
if (!empty($setting[$id])) {
foreach ($setting[$id] as $key => $value) {
$info[$key] = $value;
}
}
}
}
/**
* Implements hook_update_status_alter().
*
* Checks the 'update_test.settings:update_status' configuration and sees if we
* need to alter the update status for the given project based on the setting.
* The setting is expected to be a nested associative array. If the key '#all'
* is defined, its subarray will include .info.yml keys and values for all modules
* and themes on the system. Otherwise, the settings array is keyed by the
* module or theme short name and the subarrays contain settings just for that
* module or theme.
*/
function update_test_update_status_alter(&$projects) {
$setting = \Drupal::config('update_test.settings')
->get('update_status');
if (!empty($setting)) {
foreach ($projects as $project_name => &$project) {
foreach (array(
'#all',
$project_name,
) as $id) {
if (!empty($setting[$id])) {
foreach ($setting[$id] as $key => $value) {
$project[$key] = $value;
}
}
}
}
}
}
/**
* Implements hook_filetransfer_info().
*/
function update_test_filetransfer_info() {
// Define a mock file transfer method, to ensure that there will always be
// at least one method available in the user interface (regardless of the
// environment in which the update manager tests are run).
return array(
'system_test' => array(
'title' => t('Update Test FileTransfer'),
'class' => 'Drupal\\update_test\\MockFileTransfer',
'weight' => -20,
),
);
}
Functions
Name | Description |
---|---|
update_test_filetransfer_info | Implements hook_filetransfer_info(). |
update_test_system_info_alter | Implements hook_system_info_alter(). |
update_test_update_status_alter | Implements hook_update_status_alter(). |