Skip to content

Commit 2bcd28d

Browse files
authored
Merge pull request #138 from stof/better_config_validation
Fix the validation of incompatible options
2 parents 6c8dc49 + e347291 commit 2bcd28d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

DependencyInjection/Configuration.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,16 @@ private function configureClients(ArrayNodeDefinition $root)
155155
{
156156
$root->children()
157157
->arrayNode('clients')
158-
->validate()
159-
->ifTrue(function ($clients) {
160-
foreach ($clients as $name => $config) {
161-
// Make sure we only allow one of these to be true
162-
return (bool) $config['flexible_client'] + (bool) $config['http_methods_client'] + (bool) $config['batch_client'] >= 2;
163-
}
164-
165-
return false;
166-
})
167-
->thenInvalid('A http client can\'t be decorated with both FlexibleHttpClient and HttpMethodsClient. Only one of the following options can be true. ("flexible_client", "http_methods_client")')->end()
168158
->useAttributeAsKey('name')
169159
->prototype('array')
170160
->fixXmlConfig('plugin')
161+
->validate()
162+
->ifTrue(function ($config) {
163+
// Make sure we only allow one of these to be true
164+
return (bool) $config['flexible_client'] + (bool) $config['http_methods_client'] + (bool) $config['batch_client'] >= 2;
165+
})
166+
->thenInvalid('A http client can\'t be decorated with both FlexibleHttpClient and HttpMethodsClient. Only one of the following options can be true. ("flexible_client", "http_methods_client", "batch_client")')
167+
->end()
171168
->children()
172169
->scalarNode('factory')
173170
->isRequired()

0 commit comments

Comments
 (0)