I want to get the list of current modules and themes and modify them on Drupal 9, previously in Drupal 8,7 I used the following functions to get and save them but it seems they are depricated on Drupal 9.

 system_get_info(), _system_rebuild_module_data()

what is equivalent to these functions in Drupal 9 and how can get/update data about the module/themes in Drupal 9?

有帮助吗?

解决方案

Simply check the deprecation notice on system_get_info

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.

and the change record on _system_rebuild_module_data() and co. are replaced by services to give you all available modules and themes

// If you want to just get all extensions without rebuilding.
$module_list = \Drupal::service('extension.list.module')->getList();
许可以下: CC-BY-SA归因
scroll top