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 33
44## UNRELEASED
55
6+ ### Added
7+
8+ - Support for BatchClient
9+
610### Changed
711
812- 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)
138138 ->validate ()
139139 ->ifTrue (function ($ clients ) {
140140 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 ;
142143 }
143144
144145 return false ;
@@ -160,6 +161,10 @@ protected function configureClients(ArrayNodeDefinition $root)
160161 ->defaultFalse ()
161162 ->info ('Set to true to get the client wrapped in a HttpMethodsClient which emulates provides functions for HTTP verbs. ' )
162163 ->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 ()
163168 ->arrayNode ('plugins ' )
164169 ->info ('A list of service ids of plugins. The order is important. ' )
165170 ->prototype ('scalar ' )->end ()
Original file line number Diff line number Diff line change 22
33namespace Http \HttplugBundle \DependencyInjection ;
44
5+ use Http \Client \Common \BatchClient ;
56use Http \Client \Common \FlexibleHttpClient ;
67use Http \Client \Common \HttpMethodsClient ;
78use Http \Client \Common \Plugin \AuthenticationPlugin ;
@@ -265,6 +266,15 @@ function ($id) {
265266 ->setDecoratedService ($ serviceId )
266267 ;
267268 }
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+ }
268278 }
269279
270280 /**
You can’t perform that action at this time.
0 commit comments