Skip to content

Allow to configure the QueryDefaultsPlugin #243

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 1 commit into from
Nov 13, 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
4 changes: 4 additions & 0 deletions integrations/symfony-full-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,7 @@ This page shows an example of all configuration values provided by the bundle.
- header_remove:
# List of header names to remove
headers: ["X-FOO"]
# Sets query parameters to default value if they are not present in the request.
- query_defaults:
parameters:
locale: en
1 change: 1 addition & 0 deletions plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ request or you can even start a completely new request. This gives you full cont
headers
history
logger
query
redirect
request-uri-manipulations
retry
Expand Down
24 changes: 24 additions & 0 deletions plugins/query.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Query plugin
============

Default Query parameters
------------------------

The plugin ``QueryDefaultsPlugin`` allows you to define default values for
query parameters. If a query parameter is not set, it will be added. However, if the query parameter
is already present, the request is left unchanged. Names and values must not be URL encoded as this
plugin will encode them::

use Http\Discovery\HttpClientDiscovery;
use Http\Client\Common\PluginClient;
use Http\Client\Common\Plugin\HeaderDefaultsPlugin;

$queryDefaultsPlugin = new QueryDefaultsPlugin([
'locale' => 'en'
]);

$pluginClient = new PluginClient(
HttpClientDiscovery::find(),
[$queryDefaultsPlugin]
);