You are here

function system_get_info in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/system.module \system_get_info()

Returns an array of information about enabled modules or themes.

This function returns the contents of the .info.yml file for each installed module or theme.

Parameters

$type: Either 'module' or 'theme'.

$name: (optional) The name of a module or theme whose information shall be returned. If omitted, all records for the provided $type will be returned. If $name does not exist in the provided $type or is not enabled, an empty array will be returned.

Return value

An associative array of module or theme information keyed by name, or only information for $name, if given. If no records are available, an empty array is returned.

See also

system_rebuild_module_data()

\Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData()

11 calls to system_get_info()
AdminController::index in core/modules/system/src/Controller/AdminController.php
Prints a listing of admin tasks, organized by module.
drupal_install_profile_distribution_name in core/includes/install.inc
Loads the installation profile, extracting its defined distribution name.
drupal_install_profile_distribution_version in core/includes/install.inc
Loads the installation profile, extracting its defined version.
HelpController::helpPage in core/modules/help/src/Controller/HelpController.php
Prints a page listing general help for a module.
HelpTest::verifyHelp in core/modules/help/src/Tests/HelpTest.php
Verifies the logged in user has access to the various help nodes.

... See full list

1 string reference to 'system_get_info'
system_rebuild_module_data in core/modules/system/system.module
Rebuild, save, and return data about all currently available modules.

File

core/modules/system/system.module, line 882
Configuration system that lets administrators modify the workings of the site.

Code

function system_get_info($type, $name = NULL) {
  if ($type == 'module') {
    $info =& drupal_static(__FUNCTION__);
    if (!isset($info)) {
      if ($cache = \Drupal::cache()
        ->get('system.module.info')) {
        $info = $cache->data;
      }
      else {
        $data = system_rebuild_module_data();
        foreach (\Drupal::moduleHandler()
          ->getModuleList() as $module => $filename) {
          if (isset($data[$module])) {
            $info[$module] = $data[$module]->info;
          }
        }

        // Store the module information in cache. This cache is cleared by
        // calling system_rebuild_module_data(), for example, when listing
        // modules, (un)installing modules, importing configuration, updating
        // the site and when flushing all the caches.
        \Drupal::cache()
          ->set('system.module.info', $info);
      }
    }
  }
  else {
    $info = array();
    $list = system_list($type);
    foreach ($list as $shortname => $item) {
      if (!empty($item->status)) {
        $info[$shortname] = $item->info;
      }
    }
  }
  if (isset($name)) {
    return isset($info[$name]) ? $info[$name] : array();
  }
  return $info;
}