Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #191 from odolbeau/feat-nodes

Allow multiple servers in configuration
  • Loading branch information...
commit 1bcc518b31aa6237cfede3041785a2df1e8ef972 2 parents 5ea8bb9 + 58eaf6b
@richardmiller richardmiller authored
Showing with 34 additions and 3 deletions.
  1. +34 −3 DependencyInjection/Configuration.php
View
37 DependencyInjection/Configuration.php
@@ -45,10 +45,41 @@ private function addClientsSection(ArrayNodeDefinition $rootNode)
->useAttributeAsKey('id')
->prototype('array')
->performNoDeepMerging()
+ ->beforeNormalization()
+ ->ifTrue(function($v) { return isset($v['host']) && isset($v['port']); })
+ ->then(function($v) {
+ return array(
+ 'servers' => array(
+ 'default' => array(
+ 'host' => $v['host'],
+ 'port' => $v['port'],
+ )
+ )
+ );
+ })
+ ->end()
+ ->beforeNormalization()
+ ->ifTrue(function($v) { return isset($v['url']); })
+ ->then(function($v) {
+ return array(
+ 'servers' => array(
+ 'default' => array(
+ 'url' => $v['url'],
+ )
+ )
+ );
+ })
+ ->end()
->children()
- ->scalarNode('url')->end()
- ->scalarNode('host')->end()
- ->scalarNode('port')->end()
+ ->arrayNode('servers')
+ ->prototype('array')
+ ->children()
+ ->scalarNode('url')->end()
+ ->scalarNode('host')->end()
+ ->scalarNode('port')->end()
+ ->end()
+ ->end()
+ ->end()
->scalarNode('timeout')->end()
->scalarNode('headers')->end()
->end()
Please sign in to comment.
Something went wrong with that request. Please try again.