You are here

function system_get_info in Drupal 8

Same name and namespace in other branches
  1. 7 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.

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal::service('extension.list.$type')->getExtensionInfo() or \Drupal::service('extension.list.$type')->getAllInstalledInfo() instead.

See also

https://www.drupal.org/node/2709919

\Drupal\Core\Extension\ModuleExtensionList::getList()

\Drupal\Core\Extension\ThemeExtensionList

1 call to system_get_info()
SystemGetInfoTest::testSystemGetInfo in core/modules/system/tests/src/Kernel/System/SystemGetInfoTest.php
Tests system_get_info().

File

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

Code

function system_get_info($type, $name = NULL) {
  @trigger_error("system_get_info() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \\Drupal::service('extension.list.{$type}')->getExtensionInfo() or \\Drupal::service('extension.list.{$type}')->getAllInstalledInfo() instead. See https://www.drupal.org/node/2709919", E_USER_DEPRECATED);

  /** @var \Drupal\Core\Extension\ExtensionList $extension_list */
  $extension_list = \Drupal::service('extension.list.' . $type);
  if (isset($name)) {
    try {
      return $extension_list
        ->getExtensionInfo($name);
    } catch (\InvalidArgumentException $e) {
      return [];
    }
  }
  return $extension_list
    ->getAllInstalledInfo();
}