Combine client normalisation into a single method
This commit is contained in:
parent
57fbc70015
commit
6d2b7a8367
|
@ -60,16 +60,6 @@ class Configuration implements ConfigurationInterface
|
|||
return $treeBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the configuration tree.
|
||||
*
|
||||
* @return \Symfony\Component\DependencyInjection\Configuration\NodeInterface
|
||||
*/
|
||||
public function getConfigTree()
|
||||
{
|
||||
return $this->getConfigTreeBuilder()->buildTree();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the configuration for the "clients" key
|
||||
*/
|
||||
|
@ -83,28 +73,17 @@ class Configuration implements ConfigurationInterface
|
|||
->prototype('array')
|
||||
->performNoDeepMerging()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return isset($v['host']) && isset($v['port']); })
|
||||
->ifTrue(function($v) { return (isset($v['host']) && isset($v['port'])) || isset($v['url']); })
|
||||
->then(function($v) {
|
||||
return array(
|
||||
'servers' => array(
|
||||
array(
|
||||
'host' => $v['host'],
|
||||
'port' => $v['port'],
|
||||
'host' => isset($v['host']) ? $v['host'] : null,
|
||||
'port' => isset($v['port']) ? $v['port'] : null,
|
||||
'url' => isset($v['url']) ? $v['url'] : null,
|
||||
'logger' => isset($v['logger']) ? $v['logger'] : null,
|
||||
'headers' => isset($v['headers']) ? $v['headers'] : null,
|
||||
)
|
||||
)
|
||||
);
|
||||
})
|
||||
->end()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return isset($v['url']); })
|
||||
->then(function($v) {
|
||||
return array(
|
||||
'servers' => array(
|
||||
array(
|
||||
'url' => $v['url'],
|
||||
'logger' => isset($v['logger']) ? $v['logger'] : null
|
||||
'timeout' => isset($v['timeout']) ? $v['timeout'] : null,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue