Chris@0: baseThemeExtensions instead. Chris@18: * Chris@18: * @see https://www.drupal.org/node/3019948 Chris@0: */ Chris@0: protected $baseThemes; Chris@0: Chris@0: /** Chris@18: * An array of base theme extension objects keyed by name. Chris@18: * Chris@18: * @var \Drupal\Core\Extension\Extension[] Chris@18: */ Chris@18: protected $baseThemeExtensions = []; Chris@18: Chris@18: /** Chris@0: * The extension object. Chris@0: * Chris@0: * @var \Drupal\Core\Extension\Extension Chris@0: */ Chris@0: protected $extension; Chris@0: Chris@0: /** Chris@0: * The stylesheets which are set to be removed by the theme. Chris@0: * Chris@0: * @var array Chris@0: */ Chris@0: protected $styleSheetsRemove; Chris@0: Chris@0: /** Chris@0: * The libraries provided by the theme. Chris@0: * Chris@0: * @var array Chris@0: */ Chris@0: protected $libraries; Chris@0: Chris@0: /** Chris@0: * The regions provided by the theme. Chris@0: * Chris@0: * @var array Chris@0: */ Chris@0: protected $regions; Chris@0: Chris@0: /** Chris@0: * The libraries or library assets overridden by the theme. Chris@0: * Chris@0: * @var array Chris@0: */ Chris@0: protected $librariesOverride; Chris@0: Chris@0: /** Chris@17: * The list of libraries-extend definitions. Chris@17: * Chris@17: * @var array Chris@17: */ Chris@17: protected $librariesExtend; Chris@17: Chris@17: /** Chris@0: * Constructs an ActiveTheme object. Chris@0: * Chris@0: * @param array $values Chris@0: * The properties of the object, keyed by the names. Chris@0: */ Chris@0: public function __construct(array $values) { Chris@0: $values += [ Chris@0: 'path' => '', Chris@0: 'engine' => 'twig', Chris@0: 'owner' => 'twig', Chris@17: 'logo' => '', Chris@0: 'stylesheets_remove' => [], Chris@0: 'libraries' => [], Chris@0: 'extension' => 'html.twig', Chris@18: 'base_theme_extensions' => [], Chris@0: 'regions' => [], Chris@0: 'libraries_override' => [], Chris@0: 'libraries_extend' => [], Chris@0: ]; Chris@0: Chris@0: $this->name = $values['name']; Chris@17: $this->logo = $values['logo']; Chris@0: $this->path = $values['path']; Chris@0: $this->engine = $values['engine']; Chris@0: $this->owner = $values['owner']; Chris@0: $this->styleSheetsRemove = $values['stylesheets_remove']; Chris@0: $this->libraries = $values['libraries']; Chris@0: $this->extension = $values['extension']; Chris@18: $this->baseThemeExtensions = $values['base_theme_extensions']; Chris@18: if (!empty($values['base_themes']) && empty($this->baseThemeExtensions)) { Chris@18: @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); Chris@18: foreach ($values['base_themes'] as $base_theme) { Chris@18: $this->baseThemeExtensions[$base_theme->getName()] = $base_theme->getExtension(); Chris@18: } Chris@18: } Chris@18: Chris@0: $this->regions = $values['regions']; Chris@0: $this->librariesOverride = $values['libraries_override']; Chris@0: $this->librariesExtend = $values['libraries_extend']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the machine name of the theme. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getName() { Chris@0: return $this->name; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the path to the theme directory. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getPath() { Chris@0: return $this->path; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the theme engine. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getEngine() { Chris@0: return $this->engine; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the path to the theme engine for root themes. Chris@0: * Chris@18: * @see \Drupal\Core\Extension\ThemeExtensionList::doList() Chris@0: * Chris@0: * @return mixed Chris@0: */ Chris@0: public function getOwner() { Chris@0: return $this->owner; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the extension object. Chris@0: * Chris@0: * @return \Drupal\Core\Extension\Extension Chris@0: */ Chris@0: public function getExtension() { Chris@0: return $this->extension; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the libraries provided by the theme. Chris@0: * Chris@0: * @return mixed Chris@0: */ Chris@0: public function getLibraries() { Chris@0: return $this->libraries; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the removed stylesheets by the theme. Chris@0: * Chris@0: * @return mixed Chris@0: * Chris@0: * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Chris@0: * Chris@0: * @see https://www.drupal.org/node/2497313 Chris@0: */ Chris@0: public function getStyleSheetsRemove() { Chris@0: return $this->styleSheetsRemove; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns an array of base theme active theme objects keyed by name. Chris@0: * Chris@0: * The order starts with the base theme of $this and ends with the root of Chris@0: * the dependency chain. Chris@0: * Chris@0: * @return static[] Chris@18: * Chris@18: * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use Chris@18: * \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() instead. Chris@18: * Chris@18: * @see https://www.drupal.org/node/3019948 Chris@0: */ Chris@0: public function getBaseThemes() { Chris@18: @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); Chris@18: /** @var \Drupal\Core\Theme\ThemeInitialization $theme_initialisation */ Chris@18: $theme_initialisation = \Drupal::service('theme.initialization'); Chris@18: $base_themes = array_combine(array_keys($this->baseThemeExtensions), array_keys($this->baseThemeExtensions)); Chris@18: return array_map([$theme_initialisation, 'getActiveThemeByName'], $base_themes); Chris@18: } Chris@18: Chris@18: /** Chris@18: * Returns an array of base theme extension objects keyed by name. Chris@18: * Chris@18: * The order starts with the base theme of $this and ends with the root of Chris@18: * the dependency chain. Chris@18: * Chris@18: * @return \Drupal\Core\Extension\Extension[] Chris@18: */ Chris@18: public function getBaseThemeExtensions() { Chris@18: return $this->baseThemeExtensions; Chris@0: } Chris@0: Chris@0: /** Chris@17: * Returns the logo provided by the theme. Chris@17: * Chris@17: * @return string Chris@17: * The logo path. Chris@17: */ Chris@17: public function getLogo() { Chris@17: return $this->logo; Chris@17: } Chris@17: Chris@17: /** Chris@0: * The regions used by the theme. Chris@0: * Chris@0: * @return string[] Chris@0: * The list of region machine names supported by the theme. Chris@0: * Chris@0: * @see system_region_list() Chris@0: */ Chris@0: public function getRegions() { Chris@0: return array_keys($this->regions); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the libraries or library assets overridden by the active theme. Chris@0: * Chris@0: * @return array Chris@0: * The list of libraries overrides. Chris@0: */ Chris@0: public function getLibrariesOverride() { Chris@0: return $this->librariesOverride; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the libraries extended by the active theme. Chris@0: * Chris@0: * @return array Chris@0: * The list of libraries-extend definitions. Chris@0: */ Chris@0: public function getLibrariesExtend() { Chris@0: return $this->librariesExtend; Chris@0: } Chris@0: Chris@0: }