You are here

function system_update_8014 in Drupal 8

Install the Stable base theme if needed.

File

core/modules/system/system.install, line 2171
Install, update and uninstall functions for the system module.

Code

function system_update_8014() {
  $theme_handler = \Drupal::service('theme_handler');
  if ($theme_handler
    ->themeExists('stable')) {
    return;
  }
  $theme_handler
    ->refreshInfo();
  $theme_installer = \Drupal::service('theme_installer');
  foreach ($theme_handler
    ->listInfo() as $theme) {

    // We first check that a base theme is set because if it's set to false then
    // it's unset in
    // \Drupal\Core\Extension\ThemeExtensionList::createExtensionInfo().
    if (isset($theme->info['base theme']) && $theme->info['base theme'] == 'stable') {
      $theme_installer
        ->install([
        'stable',
      ]);
      return;
    }
  }
}