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. |
|
|
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, ortheme_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