Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By kim.pepper on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
Drupal 8 has introduced a new 'theme_handler' service for managing themes. The procedural functions from Drupal 7 have been deprecated.
Drupal 7:
$themes = list_themes(); // Get a list of available themes.
theme_enable($theme_list); // Enable themes.
theme_disable($theme_list); // Disable themes.
drupal_find_base_themes($theme, $key); // Find base themes for a theme.
system_rebuild_theme_data(); // Rebuild, save, and return data about all currently available themes.
Drupal 8:
$theme_handler = \Drupal::service('theme_handler');
$themes = $theme_handler->listInfo(); // Get a list of available themes.
$theme_handler->enable($theme_list); // Enable themes.
$theme_handler->disable($theme_list); // Disable themes.
$theme_handler->getBaseThemes($themes, $key); // Find base themes for a theme.
$theme_handler->rebuildThemeData(); // Rebuild, save, and return data about all currently available themes.
Impacts:
Module developers