Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Command/GoogleTranslateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

$file = $basePath . '/' . $messageToFileName;
$messagesTo = $this->ksortRecursive($messagesTo);
file_put_contents($file, Yaml::dump($messagesTo, 100500));
$yamlIndent = $this->getContainer()->getParameter('exercise_google_translate.yaml_indent');
file_put_contents($file, Yaml::dump($messagesTo, 100500, $yamlIndent));
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,25 @@ public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('exercise_google_translate');

$yamlIndent = array(2, 4);

$rootNode
->children()

->scalarNode('api_key')
->isRequired()
->cannotBeEmpty()
->info('key for your app https://code.google.com/apis/console/b/0/?pli=1#project:247987860421:access')
->end()

->scalarNode('yaml_indent')
->cannotBeEmpty()
->defaultValue(4)
->validate()
->ifNotInArray($yamlIndent)
->thenInvalid('The input type "%s" is not supported. Please use one of the following values: '.implode(', ', $yamlIndent))
->end()

->end()
;

Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/ExerciseGoogleTranslateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_indent', $config['yaml_indent']);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
Expand Down
1 change: 1 addition & 0 deletions Tests/App/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ framework:

exercise_google_translate:
api_key: thisistestapikey
yaml_indent: 4