function module_test_system_info_alter

Same name in other branches
  1. 7.x modules/simpletest/tests/module_test.module \module_test_system_info_alter()
  2. 9 core/modules/system/tests/modules/module_test/module_test.module \module_test_system_info_alter()
  3. 8.9.x core/modules/system/tests/modules/module_test/module_test.module \module_test_system_info_alter()
  4. 10 core/modules/system/tests/modules/module_test/module_test.module \module_test_system_info_alter()

Implements hook_system_info_alter().

Manipulate module dependencies to test dependency chains.

File

core/modules/system/tests/modules/module_test/module_test.module, line 17

Code

function module_test_system_info_alter(&$info, Extension $file, $type) {
    if (\Drupal::state()->get('module_test.dependency') == 'missing dependency') {
        if ($file->getName() == 'dblog') {
            // Make dblog module depend on config.
            $info['dependencies'][] = 'config';
        }
        elseif ($file->getName() == 'config') {
            // Make config module depend on a non-existing module.
            $info['dependencies'][] = 'foo';
        }
    }
    elseif (\Drupal::state()->get('module_test.dependency') == 'dependency') {
        if ($file->getName() == 'dblog') {
            // Make dblog module depend on config.
            $info['dependencies'][] = 'config';
        }
        elseif ($file->getName() == 'config') {
            // Make config module depend on help module.
            $info['dependencies'][] = 'help';
        }
        elseif ($file->getName() == 'entity_test') {
            // Make entity test module depend on help module.
            $info['dependencies'][] = 'help';
        }
    }
    elseif (\Drupal::state()->get('module_test.dependency') == 'version dependency') {
        if ($file->getName() == 'dblog') {
            // Make dblog module depend on config.
            $info['dependencies'][] = 'config';
        }
        elseif ($file->getName() == 'config') {
            // Make config module depend on a specific version of help module.
            $info['dependencies'][] = 'help (1.x)';
        }
        elseif ($file->getName() == 'help') {
            // Set help module to a version compatible with the above.
            $info['version'] = '8.x-1.0';
        }
    }
    if ($file->getName() == 'stark' && $type == 'theme') {
        $info['regions']['test_region'] = 'Test region';
    }
}

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