Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log


## 1.2.1 - 2016-07-19

### Fixed

- Auto discovery by using the appropriate discovery class


## 1.2.0 - 2016-07-18

### Added
Expand Down
20 changes: 15 additions & 5 deletions DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Http\Client\Common\Plugin\AuthenticationPlugin;
use Http\Client\Common\PluginClient;
use Http\Discovery\HttpAsyncClientDiscovery;
use Http\Discovery\HttpClientDiscovery;
use Http\HttplugBundle\ClientFactory\DummyClient;
use Http\HttplugBundle\Collector\DebugPlugin;
use Http\Message\Authentication\BasicAuth;
Expand Down Expand Up @@ -291,14 +292,22 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
{
$httpClient = $config['discovery']['client'];
if ($httpClient === 'auto') {
$httpClient = $this->registerAutoDiscoverableClientWithDebugPlugin($container, 'client');
$httpClient = $this->registerAutoDiscoverableClientWithDebugPlugin(
$container,
'client',
[HttpClientDiscovery::class, 'find']
);
} elseif ($httpClient) {
$httpClient = new Reference($httpClient);
}

$asyncHttpClient = $config['discovery']['async_client'];
if ($asyncHttpClient === 'auto') {
$asyncHttpClient = $this->registerAutoDiscoverableClientWithDebugPlugin($container, 'async_client');
$asyncHttpClient = $this->registerAutoDiscoverableClientWithDebugPlugin(
$container,
'async_client',
[HttpAsyncClientDiscovery::class, 'find']
);
} elseif ($asyncHttpClient) {
$asyncHttpClient = new Reference($httpClient);
}
Expand All @@ -310,15 +319,16 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra

/**
* @param ContainerBuilder $container
* @param $name
* @param string $name
* @param callable $factory
*
* @return Reference
*/
private function registerAutoDiscoverableClientWithDebugPlugin(ContainerBuilder $container, $name)
private function registerAutoDiscoverableClientWithDebugPlugin(ContainerBuilder $container, $name, $factory)
{
$definition = $container->register('httplug.auto_discovery_'.$name.'.pure', DummyClient::class);
$definition->setPublic(false);
$definition->setFactory([HttpAsyncClientDiscovery::class, 'find']);
$definition->setFactory($factory);

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