You are here

public function ConfigEventSubscriber::updateStylesheet in High contrast 8

Regenerate the stylesheet.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The Event to process.

File

src/EventSubscriber/ConfigEventSubscriber.php, line 57

Class

ConfigEventSubscriber
A subscriber for updating the stylesheet when the configuration is updated.

Namespace

Drupal\high_contrast\EventSubscriber

Code

public function updateStylesheet(ConfigCrudEvent $event) {

  // Check if the save came from the high contrast configuration.
  if ($event
    ->getConfig()
    ->getName() === 'high_contrast.settings') {
    $dir = HIGH_CONTRAST_CSS_FOLDER;
    $file = HIGH_CONTRAST_CSS_LOCATION;
    $this->fileSystem
      ->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY);
    $config = $this->configFactory
      ->get('high_contrast.settings');
    $css = _high_contrast_build_css($config
      ->get('colors_background'), $config
      ->get('colors_text'), $config
      ->get('colors_hyperlinks'));
    $this->fileSystem
      ->saveData($css, $file, FileSystemInterface::EXISTS_REPLACE);
  }
}