You are here

protected function CompileSubscriber::getConfigDependencies in Theme Compiler 2.0.x

Get a list of configuration dependencies.

The settings for any theme which defines a theme compiler asset, or the settings for any themes that depend on such a theme, will be included.

Return value

string[] A list of configuration dependencies.

1 call to CompileSubscriber::getConfigDependencies()
CompileSubscriber::onConfigChange in src/EventSubscriber/CompileSubscriber.php
Compile all assets provided by this module on configuration changes.

File

src/EventSubscriber/CompileSubscriber.php, line 82

Class

CompileSubscriber
An event subscriber used to trigger (re)compilation of this module's assets.

Namespace

Drupal\theme_compiler\EventSubscriber

Code

protected function getConfigDependencies() {
  $dependencies = [];
  $themes = [];
  foreach ($this->compiler
    ->getThemeCompilerRouteContexts() as $context) {
    if ($theme = $context
      ->getOption('theme_compiler')['theme'] ?? NULL) {
      $themes[$theme] = $theme;
    }
  }
  $info = $this->themeHandler
    ->listInfo();
  $themes = array_map(function ($theme) use ($info) {
    $result[$theme] = "{$theme}.settings";
    foreach (array_keys($info[$theme]->required_by) as $dependant) {
      $result[$dependant] = "{$dependant}.settings";
    }
    return $result;
  }, $themes);
  foreach ($themes as $dependants) {
    foreach ($dependants as $dependant) {
      $dependencies[$dependant] = $dependant;
    }
  }
  return array_values($dependencies);
}