function ThemeSettingsProvider::getSetting
File
- 
              core/
lib/ Drupal/ Core/ Extension/ ThemeSettingsProvider.php, line 51  
Class
- ThemeSettingsProvider
 - Default implementation of the theme settings provider service.
 
Namespace
Drupal\Core\ExtensionCode
public function getSetting(string $setting_name, ?string $theme = NULL) : mixed {
  // If no key is given, use the current theme if we can determine it.
  if (!isset($theme)) {
    $theme = $this->themeManager
      ->getActiveTheme()
      ->getName();
  }
  $cid = 'theme_settings:' . $theme;
  $cacheItem = $this->memoryCache
    ->get($cid);
  if ($cacheItem) {
    /** @var \Drupal\Core\Theme\ThemeSettings $themeSettings */
    $themeSettings = $cacheItem->data;
  }
  else {
    $themeSettings = $this->buildThemeSettings($theme);
    $this->memoryCache
      ->set($cid, $themeSettings, tags: [
      'config:core.extension',
      'config:system.theme.global',
      sprintf('config:%s.settings', $theme),
    ]);
  }
  return $themeSettings->get($setting_name);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.