Skip to content

Commit bd4a71c

Browse files
Merge pull request #94 from php-http/fix_discovery_factory
Fix autodiscovery
2 parents 67594a8 + 41df6da commit bd4a71c

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22

33

4+
## 1.2.1 - 2016-07-19
5+
6+
### Fixed
7+
8+
- Auto discovery by using the appropriate discovery class
9+
10+
411
## 1.2.0 - 2016-07-18
512

613
### Added

DependencyInjection/HttplugExtension.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Http\Client\Common\Plugin\AuthenticationPlugin;
88
use Http\Client\Common\PluginClient;
99
use Http\Discovery\HttpAsyncClientDiscovery;
10+
use Http\Discovery\HttpClientDiscovery;
1011
use Http\HttplugBundle\ClientFactory\DummyClient;
1112
use Http\HttplugBundle\Collector\DebugPlugin;
1213
use Http\Message\Authentication\BasicAuth;
@@ -291,14 +292,22 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
291292
{
292293
$httpClient = $config['discovery']['client'];
293294
if ($httpClient === 'auto') {
294-
$httpClient = $this->registerAutoDiscoverableClientWithDebugPlugin($container, 'client');
295+
$httpClient = $this->registerAutoDiscoverableClientWithDebugPlugin(
296+
$container,
297+
'client',
298+
[HttpClientDiscovery::class, 'find']
299+
);
295300
} elseif ($httpClient) {
296301
$httpClient = new Reference($httpClient);
297302
}
298303

299304
$asyncHttpClient = $config['discovery']['async_client'];
300305
if ($asyncHttpClient === 'auto') {
301-
$asyncHttpClient = $this->registerAutoDiscoverableClientWithDebugPlugin($container, 'async_client');
306+
$asyncHttpClient = $this->registerAutoDiscoverableClientWithDebugPlugin(
307+
$container,
308+
'async_client',
309+
[HttpAsyncClientDiscovery::class, 'find']
310+
);
302311
} elseif ($asyncHttpClient) {
303312
$asyncHttpClient = new Reference($httpClient);
304313
}
@@ -310,15 +319,16 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
310319

311320
/**
312321
* @param ContainerBuilder $container
313-
* @param $name
322+
* @param string $name
323+
* @param callable $factory
314324
*
315325
* @return Reference
316326
*/
317-
private function registerAutoDiscoverableClientWithDebugPlugin(ContainerBuilder $container, $name)
327+
private function registerAutoDiscoverableClientWithDebugPlugin(ContainerBuilder $container, $name, $factory)
318328
{
319329
$definition = $container->register('httplug.auto_discovery_'.$name.'.pure', DummyClient::class);
320330
$definition->setPublic(false);
321-
$definition->setFactory([HttpAsyncClientDiscovery::class, 'find']);
331+
$definition->setFactory($factory);
322332

323333
$serviceIdDebugPlugin = $this->registerDebugPlugin($container, 'auto_discovery_'.$name);
324334
$container->register('httplug.auto_discovery_'.$name.'.plugin', PluginClient::class)

0 commit comments

Comments
 (0)