Skip to content

Commit 5f711c3

Browse files
committed
Make it possible to create public httplug clients
1 parent 853c4f6 commit 5f711c3

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
## 1.12.0 - 2018-10-24
6+
7+
### Added
8+
9+
- Add configuration option to create public clients
10+
511
## 1.11.0 - 2018-07-07
612

713
### Added

DependencyInjection/Configuration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ private function configureClients(ArrayNodeDefinition $root)
195195
->defaultNull()
196196
->info('The service id of the client to use.')
197197
->end()
198+
->booleanNode('public')
199+
->defaultFalse()
200+
->info('Set to true if you really cannot use dependency injection and need to make the client service public.')
201+
->end()
198202
->booleanNode('flexible_client')
199203
->defaultFalse()
200204
->info('Set to true to get the client wrapped in a FlexibleHttpClient which emulates async or sync behavior.')

DependencyInjection/HttplugExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ private function configureClient(ContainerBuilder $container, $clientName, array
325325

326326
$container
327327
->register($serviceId, PluginClient::class)
328+
->setPublic($arguments['public'])
328329
->setFactory([new Reference(PluginClientFactory::class), 'createClient'])
329330
->addArgument(new Reference($serviceId.'.client'))
330331
->addArgument(

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public function testSupportsAllConfigFormats()
119119
'factory' => 'httplug.factory.guzzle6',
120120
'http_methods_client' => true,
121121
'service' => null,
122+
'public' => false,
122123
'flexible_client' => false,
123124
'batch_client' => false,
124125
'plugins' => [

Tests/Unit/DependencyInjection/HttplugExtensionTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,30 @@ private function verifyProfilingDisabled()
267267
);
268268
}
269269
}
270+
271+
public function testClientShouldBePrivatByDefault()
272+
{
273+
$this->load([
274+
'clients' => [
275+
'acme' => [],
276+
],
277+
]);
278+
279+
$this->assertContainerBuilderHasService('httplug.client.acme');
280+
$this->assertFalse($this->container->getDefinition('httplug.client.acme')->isPublic());
281+
}
282+
283+
public function testClientCanBePublic()
284+
{
285+
$this->load([
286+
'clients' => [
287+
'acme' => [
288+
'public' => true,
289+
],
290+
],
291+
]);
292+
293+
$this->assertContainerBuilderHasService('httplug.client.acme');
294+
$this->assertTrue($this->container->getDefinition('httplug.client.acme')->isPublic());
295+
}
270296
}

0 commit comments

Comments
 (0)