Change record status: 
Project: 
Introduced in branch: 
8.7.x
Introduced in version: 
8.7.0
Description: 

Drupal has a couple of methods internally to handle the location of modules/themes, the rebuilding of that information etc.

This all consolidated in the extension.list.module, extension.list.profile and extension.list.theme services:

Before After
system_get_info('module')
system_get_info('profile')
system_get_info('theme')
system_get_info('theme_engine')
\Drupal::service('extension.list.module')->getAllInstalledInfo()
\Drupal::service('extension.list.profile')->getAllInstalledInfo()
\Drupal::service('extension.list.theme')->getAllInstalledInfo()
\Drupal::service('extension.list.theme_engine')->getAllInstalledInfo()
system_get_info('module', 'module_name')
system_get_info('profile', 'profile_name')
system_get_info('theme', 'theme_name')
system_get_info('theme_engine', 'theme_engine_name')
\Drupal::service('extension.list.module')->getExtensionInfo('module_name')
\Drupal::service('extension.list.profile')->getExtensionInfo('profile_name')
\Drupal::service('extension.list.theme')->getExtensionInfo('theme_name')
\Drupal::service('extension.list.theme_engine')->getExtensionInfo('theme_engine_name')
system_list('theme')
Note that system_list() has never accepted a type other than theme or filepaths in Drupal 8
\Drupal::service('theme_handler')->listInfo()
system_list_reset() If contrib or custom is using it and its functionality is really required they can either rebuild the container or call each \Drupal::service('extension.list.TYPE')->reset() as necessary. Note this is now often not required because the caches are cleared when the container is rebuilt.
// Multiple uses.
system_rebuild_module_data()
// If you just want to rebuild the module information.
\Drupal::service('extension.list.module')->reset();

// If you want to actually rebuild the information first before getting all extensions.
$module_list = \Drupal::service('extension.list.module')->reset()->getList();

// If you want to just get all extensions without rebuilding.
$module_list = \Drupal::service('extension.list.module')->getList();
system_register() Not used anymore in core. There is no direct replacement.

What are extensions?

Extensions are modules, themes, profiles or theme engines. Extensions are represented by the \Drupal\Core\Extension\Extension object which holds information about the location in the filesystem:

  • type: Either module, profile, theme, or theme_engine
  • name: The name of the extension e.g. system.
  • path: The location of the extension in the file system
  • pathname: The full path to the extension's .info.yml file

What is extension info?

Extension info is an array of data parsed from the extension's .info.yml file.
For all extensions:

name: System
type: module
description: 'Handles general site configuration for administrators.'
package: Core
version: VERSION
core: 8.x

Additional module-specific info:

required: true
configure: system.admin_config_system
dependencies: [ ]

Additional theme-specific info:

libraries: [ ]
ckeditor_stylesheets: [ ]
regions: { }
libraries-override: { }
libraries-extend: [ ]

Additional profile-specific info:

dependencies: [ ]
themes: [ ]

For more information on the Extension object, see https://www.drupal.org/node/2198695

Impacts: 
Module developers
Themers
Site templates, recipes and distribution developers