Gets the theme directories sorted by hierarchy.
string[] The sorted theme directories array.
protected function getSortedThemeDirectories() {
$theme_directories = $this->themeHandler
->getThemeDirectories();
$themes = $this->themeHandler
->listInfo();
$sorted_themes = [];
// Loop over all themes and loop over their base themes.
foreach ($themes as $theme) {
if (isset($theme->base_themes)) {
foreach (array_keys($theme->base_themes) as $base_theme) {
// If the theme has not been added yet, add it.
if (!isset($sorted_themes[$base_theme])) {
$sorted_themes[$base_theme] = TRUE;
}
}
}
// If the theme has not been added yet, add it.
if (!isset($sorted_themes[$theme
->getName()])) {
$sorted_themes[$theme
->getName()] = TRUE;
}
}
// Sort the theme directories based on the theme keys.
return array_replace($sorted_themes, $theme_directories);
}