File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 3
3
4
4
## UNRELEASED
5
5
6
+ ### Added
7
+
8
+ - Support for BatchClient
9
+
6
10
### Changed
7
11
8
12
- All clients are registered with the PluginClient (even in production)
Original file line number Diff line number Diff line change @@ -138,7 +138,8 @@ protected function configureClients(ArrayNodeDefinition $root)
138
138
->validate ()
139
139
->ifTrue (function ($ clients ) {
140
140
foreach ($ clients as $ name => $ config ) {
141
- return $ config ['flexible_client ' ] && $ config ['http_methods_client ' ];
141
+ // Make sure we only allow one of these to be true
142
+ return (bool ) $ config ['flexible_client ' ] + (bool ) $ config ['http_methods_client ' ] + (bool ) $ config ['batch_client ' ] >= 2 ;
142
143
}
143
144
144
145
return false ;
@@ -160,6 +161,10 @@ protected function configureClients(ArrayNodeDefinition $root)
160
161
->defaultFalse ()
161
162
->info ('Set to true to get the client wrapped in a HttpMethodsClient which emulates provides functions for HTTP verbs. ' )
162
163
->end ()
164
+ ->booleanNode ('batch_client ' )
165
+ ->defaultFalse ()
166
+ ->info ('Set to true to get the client wrapped in a BatchClient which allows you to send multiple request at the same time. ' )
167
+ ->end ()
163
168
->arrayNode ('plugins ' )
164
169
->info ('A list of service ids of plugins. The order is important. ' )
165
170
->prototype ('scalar ' )->end ()
Original file line number Diff line number Diff line change 2
2
3
3
namespace Http \HttplugBundle \DependencyInjection ;
4
4
5
+ use Http \Client \Common \BatchClient ;
5
6
use Http \Client \Common \FlexibleHttpClient ;
6
7
use Http \Client \Common \HttpMethodsClient ;
7
8
use Http \Client \Common \Plugin \AuthenticationPlugin ;
@@ -265,6 +266,15 @@ function ($id) {
265
266
->setDecoratedService ($ serviceId )
266
267
;
267
268
}
269
+
270
+ if ($ arguments ['batch_client ' ]) {
271
+ $ container
272
+ ->register ($ serviceId .'.batch_client ' , BatchClient::class)
273
+ ->setArguments ([new Reference ($ serviceId .'.batch_client.inner ' )])
274
+ ->setPublic (false )
275
+ ->setDecoratedService ($ serviceId )
276
+ ;
277
+ }
268
278
}
269
279
270
280
/**
You can’t perform that action at this time.
0 commit comments