You are here

function toolbar_themes_get_theme_definitions in Toolbar Themes 8

Finds all instances of [extension type].toolbar_themes.yml and caches theme definitions.

Return value

array|\mixed[]

3 calls to toolbar_themes_get_theme_definitions()
ToolbarThemesSettingsForm::buildForm in src/Form/ToolbarThemesSettingsForm.php
Form constructor.
toolbar_themes_get_library_names in ./toolbar_themes.module
Return all themes libraries.
toolbar_themes_get_theme_definition in ./toolbar_themes.module
Return a themes definitions.

File

./toolbar_themes.module, line 12

Code

function toolbar_themes_get_theme_definitions() {
  if ($cache = \Drupal::cache()
    ->get('toolbar_themes:definitions')) {
    $definitions = $cache->data;
  }
  else {
    $theme_handler = \Drupal::service('theme_handler');
    $module_handler = \Drupal::service('module_handler');
    $discovery = new YamlDiscovery('toolbar_themes', $module_handler
      ->getModuleDirectories() + $theme_handler
      ->getThemeDirectories());
    $definitions = $discovery
      ->findAll();
    if (!empty($definitions)) {
      \Drupal::cache()
        ->set('toolbar_themes:definitions', $definitions);
    }
  }
  return $definitions;
}