protected function StyleDiscovery::getSortedThemeDirectories in Paragraphs Collection 8
Gets the theme directories sorted by hierarchy.
Return value
string[] The sorted theme directories array.
2 calls to StyleDiscovery::getSortedThemeDirectories()
- StyleDiscovery::getYamlDiscovery in src/
StyleDiscovery.php - Gets the YAML discovery.
- StyleDiscovery::getYamlGroupDiscovery in src/
StyleDiscovery.php - Gets the YAML group discovery.
File
- src/
StyleDiscovery.php, line 216
Class
- StyleDiscovery
- Provides common helper methods for style discovery. @todo Create documentation for style discovery https://www.drupal.org/node/2837995
Namespace
Drupal\paragraphs_collectionCode
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);
}