update_script_test.install

Same filename in other branches
  1. 7.x modules/simpletest/tests/update_script_test.install
  2. 9 core/modules/system/tests/modules/update_script_test/update_script_test.install
  3. 8.9.x core/modules/system/tests/modules/update_script_test/update_script_test.install
  4. 10 core/modules/system/tests/modules/update_script_test/update_script_test.install

File

core/modules/system/tests/modules/update_script_test/update_script_test.install

View source
<?php


/**
 * @file
 * Install, update and uninstall functions for the update_script_test module.
 */
declare (strict_types=1);

/**
 * Implements hook_requirements().
 */
function update_script_test_requirements($phase) {
    $requirements = [];
    if ($phase == 'update') {
        // Set a requirements warning or error when the test requests it.
        $requirement_type = \Drupal::config('update_script_test.settings')->get('requirement_type');
        switch ($requirement_type) {
            case REQUIREMENT_WARNING:
                $requirements['update_script_test'] = [
                    'title' => 'Update script test',
                    'value' => 'Warning',
                    'description' => 'This is a requirements warning provided by the update_script_test module.',
                    'severity' => REQUIREMENT_WARNING,
                ];
                break;
            case REQUIREMENT_ERROR:
                $requirements['update_script_test'] = [
                    'title' => 'Update script test',
                    'value' => 'Error',
                    'description' => 'This is a (buggy description fixed in update_script_test_requirements_alter()) requirements error provided by the update_script_test module.',
                    'severity' => REQUIREMENT_ERROR,
                ];
                break;
        }
    }
    return $requirements;
}

/**
 * Implements hook_requirements_alter().
 */
function update_script_test_requirements_alter(array &$requirements) : void {
    if (isset($requirements['update_script_test']) && $requirements['update_script_test']['severity'] === REQUIREMENT_ERROR) {
        $requirements['update_script_test']['description'] = 'This is a requirements error provided by the update_script_test module.';
    }
}

/**
 * Implements hook_update_last_removed().
 */
function update_script_test_update_last_removed() {
    return 7110;
}

/**
 * Dummy update_script_test update 7200.
 */
function update_script_test_update_7200() {
    return 'The update_script_test_update_7200() update was executed successfully.';
}

/**
 * Dummy update_script_test update 7201.
 */
function update_script_test_update_7201() {
    return 'The update_script_test_update_7201() update was executed successfully.';
}

/**
 * Dummy update function to run during the tests.
 */
function update_script_test_update_8001() {
    return 'The update_script_test_update_8001() update was executed successfully.';
}

Functions

Title Deprecated Summary
update_script_test_requirements Implements hook_requirements().
update_script_test_requirements_alter Implements hook_requirements_alter().
update_script_test_update_7200 Dummy update_script_test update 7200.
update_script_test_update_7201 Dummy update_script_test update 7201.
update_script_test_update_8001 Dummy update function to run during the tests.
update_script_test_update_last_removed Implements hook_update_last_removed().

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