I was building a block for which I have to provide bubblable metadata. The data in this block is depending on individual theme configurations as well as the global theme settings.
So I tried the following:
$config = \Drupal::config('system.theme.global'); $bubbleable_metadata->addCacheableDependency($config); $config2 = \Drupal::config('bartik.settings'); $bubbleable_metadata->addCacheableDependency($config2);
This however obviously does not work if the theme is not set to bartik. I have been attempting to find the theme configuration in
\Drupal::theme()->getActiveTheme(), but that does not provide this data.
I suppose I could try
$config = \Drupal::theme()->getActiveTheme()->getName() . '.settings';, but I'd like to learn if there are better ways.
How to get the configuration (or config name) of the current active theme?