function TestController::showModuleInfo

Same name in other branches
  1. 10 core/modules/system/tests/modules/container_rebuild_test/src/TestController.php \Drupal\container_rebuild_test\TestController::showModuleInfo()
  2. 11.x core/modules/system/tests/modules/container_rebuild_test/src/TestController.php \Drupal\container_rebuild_test\TestController::showModuleInfo()

Displays the path to a module.

Parameters

string $module: The module name.

string $function: The function to check if it exists.

Return value

string[] A render array.

1 string reference to 'TestController::showModuleInfo'
container_rebuild_test.routing.yml in core/modules/system/tests/modules/container_rebuild_test/container_rebuild_test.routing.yml
core/modules/system/tests/modules/container_rebuild_test/container_rebuild_test.routing.yml

File

core/modules/system/tests/modules/container_rebuild_test/src/TestController.php, line 20

Class

TestController

Namespace

Drupal\container_rebuild_test

Code

public function showModuleInfo(string $module, string $function) {
    $module_handler = \Drupal::moduleHandler();
    $module_message = $module . ': ';
    if ($module_handler->moduleExists($module)) {
        $module_message .= \Drupal::moduleHandler()->getModule($module)
            ->getPath();
    }
    else {
        $module_message .= 'not installed';
    }
    $function_message = $function . ': ' . var_export(function_exists($function), TRUE);
    return [
        '#theme' => 'item_list',
        '#items' => [
            $module_message,
            $function_message,
        ],
    ];
}

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