From 6b1d69472cfb54931cddbc2b94544066c5b30806 Mon Sep 17 00:00:00 2001 From: Remiii Date: Thu, 7 May 2015 13:36:51 +0200 Subject: [PATCH] ADD YAML keys sorting configuration --- Command/GoogleTranslateCommand.php | 6 +++++- DependencyInjection/Configuration.php | 5 +++++ DependencyInjection/ExerciseGoogleTranslateExtension.php | 1 + Tests/App/config.yml | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Command/GoogleTranslateCommand.php b/Command/GoogleTranslateCommand.php index 440ecbf..df67e6b 100644 --- a/Command/GoogleTranslateCommand.php +++ b/Command/GoogleTranslateCommand.php @@ -74,7 +74,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(sprintf('Creating "%s" file', $messageToFileName)); $file = $basePath . '/' . $messageToFileName; - $messagesTo = $this->ksortRecursive($messagesTo); + $yamlKeysSorting = $this->getContainer()->getParameter('exercise_google_translate.yaml_keys_sorting'); + if ( $yamlKeysSorting ) + { + $messagesTo = $this->ksortRecursive($messagesTo); + } file_put_contents($file, Yaml::dump($messagesTo, 100500)); } } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 1e0d63d..aa5fb84 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -27,6 +27,11 @@ public function getConfigTreeBuilder() ->cannotBeEmpty() ->info('key for your app https://code.google.com/apis/console/b/0/?pli=1#project:247987860421:access') ->end() + + ->booleanNode('yaml_keys_sorting') + ->defaultValue(true) + ->end() + ->end() ; diff --git a/DependencyInjection/ExerciseGoogleTranslateExtension.php b/DependencyInjection/ExerciseGoogleTranslateExtension.php index d6fae30..5264788 100644 --- a/DependencyInjection/ExerciseGoogleTranslateExtension.php +++ b/DependencyInjection/ExerciseGoogleTranslateExtension.php @@ -24,6 +24,7 @@ public function load(array $configs, ContainerBuilder $container) $rootNode = $configuration->getConfigTreeBuilder()->buildTree()->getName(); $container->setParameter($rootNode.'.api_key', $config['api_key']); + $container->setParameter($rootNode.'.yaml_keys_sorting', $config['yaml_keys_sorting']); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); diff --git a/Tests/App/config.yml b/Tests/App/config.yml index b8b4b83..9cdc15f 100644 --- a/Tests/App/config.yml +++ b/Tests/App/config.yml @@ -4,3 +4,4 @@ framework: exercise_google_translate: api_key: thisistestapikey + yaml_keys_sorting: true