You are here

public function TestController::showModuleInfo in Drupal 10

Same name and namespace in other branches
  1. 9 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,
    ],
  ];
}