Skip to content

Add AddPathPlugin support. ISSUE-255 #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 8, 2018
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## 1.10.0 (unreleased) - 2018-03-09

### Added

- Allow to configure the `AddPathPlugin` per client, under the `add_path` configuration key.

## 1.9.0 - 2018-03-06

### Added
Expand Down
12 changes: 12 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@ private function createClientPluginNode()
->end()
->end()
->end()
->arrayNode('add_path')
->canBeEnabled()
->addDefaultsIfNotSet()
->info('Add a base path to the request.')
->children()
->scalarNode('path')
->info('Path to be added, e.g. /api/v1')
->isRequired()
->cannotBeEmpty()
->end()
->end()
->end()
->arrayNode('base_uri')
->canBeEnabled()
->addDefaultsIfNotSet()
Expand Down
6 changes: 6 additions & 0 deletions DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ private function configurePluginByName($name, Definition $definition, array $con
'replace' => $config['replace'],
]);

break;
case 'add_path':
$pathUriService = $serviceId.'.path_uri';
$this->createUri($container, $pathUriService, $config['path']);
$definition->replaceArgument(0, new Reference($pathUriService));

break;
case 'base_uri':
$baseUriService = $serviceId.'.base_uri';
Expand Down
3 changes: 3 additions & 0 deletions Resources/config/plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<argument/>
<argument/>
</service>
<service id="httplug.plugin.add_path" class="Http\Client\Common\Plugin\AddPathPlugin" public="false" abstract="true">
<argument/>
</service>
<service id="httplug.plugin.base_uri" class="Http\Client\Common\Plugin\BaseUriPlugin" public="false" abstract="true">
<argument/>
<argument/>
Expand Down
5 changes: 5 additions & 0 deletions Tests/Resources/Fixtures/config/full.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
'host' => 'http://localhost',
],
],
[
'add_path' => [
'path' => '/api/v1',
],
],
[
'base_uri' => [
'uri' => 'http://localhost',
Expand Down
3 changes: 3 additions & 0 deletions Tests/Resources/Fixtures/config/full.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<plugin>
<add-host host="http://localhost"/>
</plugin>
<plugin>
<add-path path="/api/v1"/>
</plugin>
<plugin>
<base-uri uri="http://localhost"/>
</plugin>
Expand Down
3 changes: 3 additions & 0 deletions Tests/Resources/Fixtures/config/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ httplug:
-
add_host:
host: http://localhost
-
add_path:
path: /api/v1
-
base_uri:
uri: http://localhost
Expand Down
6 changes: 6 additions & 0 deletions Tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ public function testSupportsAllConfigFormats()
'replace' => false,
],
],
[
'add_path' => [
'enabled' => true,
'path' => '/api/v1',
],
],
[
'base_uri' => [
'enabled' => true,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.10-dev"
}
}
}