You are here

public function ThemeGenerator::replaceCloneConfigSettings in AT Tools 8.3

Same name and namespace in other branches
  1. 8.2 at_theme_generator/src/Theme/ThemeGenerator.php \Drupal\at_theme_generator\Theme\ThemeGenerator::replaceCloneConfigSettings()

Replace the installation config with the clone sources active config.

1 call to ThemeGenerator::replaceCloneConfigSettings()
ThemeGeneratorTypes::cloneGenerator in at_theme_generator/src/Theme/ThemeGeneratorTypes.php
Generate clone type theme.

File

at_theme_generator/src/Theme/ThemeGenerator.php, line 279

Class

ThemeGenerator
Generator form.

Namespace

Drupal\at_theme_generator\Theme

Code

public function replaceCloneConfigSettings() {

  // Empty if the source theme has never been installed, in which case it
  // should be safe to assume there is no new configuration worth saving.
  if (!empty($this->clone_source_config)) {

    // Remove the default config hash.
    if (array_key_exists('_core', $this->clone_source_config)) {
      unset($this->clone_source_config['_core']);
    }
    $old_config = "{$this->target}/config/install/{$this->machine_name}.settings.yml";
    $new_config = Yaml::encode($this->clone_source_config);
    $find_generated_files = "themes/{$this->clone_source}/styles/css/generated";
    $replace_generated_files = "themes/{$this->machine_name}/styles/css/generated";
    $new_config = str_replace($find_generated_files, $replace_generated_files, $new_config);
    $this->fileOperations
      ->fileReplace($new_config, $old_config);
    $this->fileOperations
      ->fileStrReplace($old_config, $this->clone_source, $this->machine_name);
  }
}