eventName = $this->getName(); $this ->setName('build:merge_params') ->setDescription('Step 1: merges the params.local.yml with dist.params.local.yml.') ->setDefinition([]) ->setHelp( << NULL]); $merged['sites'] = []; foreach ($sites as $name => $params) { $merged['sites'][$name] = NestedArray::mergeDeep($default, $params); } return $merged; } /** * Executes the current command. * * {@inheritDoc} */ public function execute(InputInterface $input, OutputInterface $output) { $settingsPath = $this->getSettingsPath(); $yaml = new Yaml(); // Load defaults. $defaultsPath = "${settingsPath}/dist.params.local.yml"; $realDefaultsPath = realpath($defaultsPath); if (empty($realDefaultsPath)) { $output->writeln("Failed to open $defaultsPath"); return 1; } $defaults = $yaml->parseFile($realDefaultsPath); // Load local. $localPath = "${settingsPath}/params.local.yml"; $realLocalPath = realpath($localPath); if (empty($realLocalPath)) { if ($output->isVerbose()) { $output->writeln("File $localPath not found, using only defaults"); } $local = []; } else { $local = $yaml->parseFile($realLocalPath); } // Merge. $merged = $this->merge($defaults, $local); // Write. $ok = file_put_contents("${settingsPath}/merged.params.local.yml", $yaml->dump($merged, 10, 2)); if (!$ok) { $output->writeln("Failed to write merged params."); return 2; } } }