diff core/lib/Drupal/Core/Theme/ActiveTheme.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
line wrap: on
line diff
--- a/core/lib/Drupal/Core/Theme/ActiveTheme.php	Thu Feb 28 13:11:55 2019 +0000
+++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php	Thu May 09 15:34:47 2019 +0100
@@ -51,10 +51,22 @@
    * An array of base theme active theme objects keyed by name.
    *
    * @var static[]
+   *
+   * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9. Use
+   *   $this->baseThemeExtensions instead.
+   *
+   * @see https://www.drupal.org/node/3019948
    */
   protected $baseThemes;
 
   /**
+   * An array of base theme extension objects keyed by name.
+   *
+   * @var \Drupal\Core\Extension\Extension[]
+   */
+  protected $baseThemeExtensions = [];
+
+  /**
    * The extension object.
    *
    * @var \Drupal\Core\Extension\Extension
@@ -111,7 +123,7 @@
       'stylesheets_remove' => [],
       'libraries' => [],
       'extension' => 'html.twig',
-      'base_themes' => [],
+      'base_theme_extensions' => [],
       'regions' => [],
       'libraries_override' => [],
       'libraries_extend' => [],
@@ -125,7 +137,14 @@
     $this->styleSheetsRemove = $values['stylesheets_remove'];
     $this->libraries = $values['libraries'];
     $this->extension = $values['extension'];
-    $this->baseThemes = $values['base_themes'];
+    $this->baseThemeExtensions = $values['base_theme_extensions'];
+    if (!empty($values['base_themes']) && empty($this->baseThemeExtensions)) {
+      @trigger_error("The 'base_themes' key is deprecated in Drupal 8.7.0  and support for it will be removed in Drupal 9.0.0. Use 'base_theme_extensions' instead. See https://www.drupal.org/node/3019948", E_USER_DEPRECATED);
+      foreach ($values['base_themes'] as $base_theme) {
+        $this->baseThemeExtensions[$base_theme->getName()] = $base_theme->getExtension();
+      }
+    }
+
     $this->regions = $values['regions'];
     $this->librariesOverride = $values['libraries_override'];
     $this->librariesExtend = $values['libraries_extend'];
@@ -161,7 +180,7 @@
   /**
    * Returns the path to the theme engine for root themes.
    *
-   * @see \Drupal\Core\Extension\ThemeHandler::rebuildThemeData
+   * @see \Drupal\Core\Extension\ThemeExtensionList::doList()
    *
    * @return mixed
    */
@@ -207,9 +226,30 @@
    * the dependency chain.
    *
    * @return static[]
+   *
+   * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use
+   *   \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() instead.
+   *
+   * @see https://www.drupal.org/node/3019948
    */
   public function getBaseThemes() {
-    return $this->baseThemes;
+    @trigger_error('\Drupal\Core\Theme\ActiveTheme::getBaseThemes() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() instead. See https://www.drupal.org/node/3019948', E_USER_DEPRECATED);
+    /** @var \Drupal\Core\Theme\ThemeInitialization $theme_initialisation */
+    $theme_initialisation = \Drupal::service('theme.initialization');
+    $base_themes = array_combine(array_keys($this->baseThemeExtensions), array_keys($this->baseThemeExtensions));
+    return array_map([$theme_initialisation, 'getActiveThemeByName'], $base_themes);
+  }
+
+  /**
+   * Returns an array of base theme extension objects keyed by name.
+   *
+   * The order starts with the base theme of $this and ends with the root of
+   * the dependency chain.
+   *
+   * @return \Drupal\Core\Extension\Extension[]
+   */
+  public function getBaseThemeExtensions() {
+    return $this->baseThemeExtensions;
   }
 
   /**