Change record status: 
Project: 
Introduced in branch: 
8.0.x
Description: 

In Drupal 7 you could access and set the current active theme via global variables like $GLOBALS['theme_key'] and $GLOBALS['theme'].
In Drupal 8 this is replaced by an ActiveTheme object available via the 'theme.manager' service:

Example code in Drupal 7:

drupal_set_message(t("Active theme name: @name", array('@name' => $GLOBALS['theme_key'])));

Code in Drupal 8:

drupal_set_message(t("Active theme name: @name", array('@name' => \Drupal::theme()->getActiveTheme()->getName())));

On top of the theme name the ActiveTheme (\Drupal\Core\Theme\ActiveTheme) object provides all runtime information needed about the active theme, like the path to the active theme:

Code in Drupal 7

path_to_theme();

Code in Drupal 8

\Drupal::theme()->getActiveTheme()->getPath();
Impacts: 
Module developers
Themers