Loading high_contrast.services.yml +1 −1 Changes for high_contrast.services.yml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -7,6 +7,6 @@ services: high_contrast.overrider: class: \Drupal\high_contrast\HighContrastConfigOverride arguments: ['@config.factory'] arguments: ['@config.factory', '@file_system'] tags: - { name: config.factory.override } src/HighContrastConfigOverride.php +29 −3 Changes for src/HighContrastConfigOverride.php: 29 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\File\Exception\FileException; use Drupal\Core\File\FileSystemInterface; /** * Configuration override class for high contrast. Loading @@ -21,8 +23,24 @@ class HighContrastConfigOverride implements ConfigFactoryOverrideInterface { */ private $configFactory; public function __construct(ConfigFactoryInterface $config_factory) { /** * The file system interface. * * @var \Drupal\Core\File\FileSystemInterface */ private $fileSystem; /** * Construct a new HighContrastConfigOverride object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\File\FileSystemInterface $file_system * The file system. */ public function __construct(ConfigFactoryInterface $config_factory, FileSystemInterface $file_system) { $this->configFactory = $config_factory; $this->fileSystem = $file_system; } /** Loading Loading @@ -88,11 +106,19 @@ class HighContrastConfigOverride implements ConfigFactoryOverrideInterface { $theme = \Drupal::service('theme.manager')->getActiveTheme()->getName(); $theme_path = drupal_get_path('theme', $theme); $candidates = file_scan_directory($theme_path, "/logo_hg\.(svg|png|jpg|gif)$/"); if ($candidates) { $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'); Loading Loading
high_contrast.services.yml +1 −1 Changes for high_contrast.services.yml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -7,6 +7,6 @@ services: high_contrast.overrider: class: \Drupal\high_contrast\HighContrastConfigOverride arguments: ['@config.factory'] arguments: ['@config.factory', '@file_system'] tags: - { name: config.factory.override }
src/HighContrastConfigOverride.php +29 −3 Changes for src/HighContrastConfigOverride.php: 29 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\File\Exception\FileException; use Drupal\Core\File\FileSystemInterface; /** * Configuration override class for high contrast. Loading @@ -21,8 +23,24 @@ class HighContrastConfigOverride implements ConfigFactoryOverrideInterface { */ private $configFactory; public function __construct(ConfigFactoryInterface $config_factory) { /** * The file system interface. * * @var \Drupal\Core\File\FileSystemInterface */ private $fileSystem; /** * Construct a new HighContrastConfigOverride object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\File\FileSystemInterface $file_system * The file system. */ public function __construct(ConfigFactoryInterface $config_factory, FileSystemInterface $file_system) { $this->configFactory = $config_factory; $this->fileSystem = $file_system; } /** Loading Loading @@ -88,11 +106,19 @@ class HighContrastConfigOverride implements ConfigFactoryOverrideInterface { $theme = \Drupal::service('theme.manager')->getActiveTheme()->getName(); $theme_path = drupal_get_path('theme', $theme); $candidates = file_scan_directory($theme_path, "/logo_hg\.(svg|png|jpg|gif)$/"); if ($candidates) { $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'); Loading