private function HighContrastConfigOverride::getHighContrastLogo in High contrast 8
Returns the configured logo, either from theme dir of configured path.
1 call to HighContrastConfigOverride::getHighContrastLogo()
- HighContrastConfigOverride::loadOverrides in src/
HighContrastConfigOverride.php - @todo Override the right logo. See https://www.drupal.org/node/2866194
File
- src/
HighContrastConfigOverride.php, line 99
Class
- HighContrastConfigOverride
- Configuration override class for high contrast.
Namespace
Drupal\high_contrastCode
private function getHighContrastLogo() {
$logo = NULL;
$config = $this->configFactory
->get('high_contrast.settings');
if ($config
->get('default_logo')) {
// If the default logo is desired, scan the theme dir for a logo-hg file.
// Not using dependency injection to prevent circular references.
$theme = \Drupal::theme()
->getActiveTheme()
->getName();
$theme_path = drupal_get_path('theme', $theme);
$candidates = [];
try {
if (is_dir($theme_path)) {
$candidates = $this->fileSystem
->scanDirectory($theme_path, "/logo_hg\\.(svg|png|jpg|gif)\$/");
}
if (!empty($candidates)) {
$logo = reset($candidates)->uri;
}
} catch (FileException $e) {
// Ignore and return empty array for BC.
}
}
elseif ($config
->get('logo_path')) {
// No default logo, return the custom logo instead.
$logo = $config
->get('logo_path');
}
return $logo;
}