Skip to content

fix plugin instantiation #113

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
Aug 8, 2016
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: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

## UNRELEASED

### Fixed

- decoder, redirect and retry plugins can now be used and no longer trigger an error because of incorrect constructor arguments.

### Added

- Support for BatchClient
- The stopwatch plugin in included by default when using profiling.
- The stopwatch plugin in included by default when using profiling.

### Changed

Expand Down
5 changes: 3 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function getConfigTreeBuilder()
return $v;
})
->end()
->fixXmlConfig('client')
->children()
->arrayNode('main_alias')
->addDefaultsIfNotSet()
Expand Down Expand Up @@ -150,7 +151,7 @@ public function getConfigTreeBuilder()
return $treeBuilder;
}

protected function configureClients(ArrayNodeDefinition $root)
private function configureClients(ArrayNodeDefinition $root)
{
$root->children()
->arrayNode('clients')
Expand Down Expand Up @@ -196,7 +197,7 @@ protected function configureClients(ArrayNodeDefinition $root)
/**
* @param ArrayNodeDefinition $root
*/
protected function configurePlugins(ArrayNodeDefinition $root)
private function configurePlugins(ArrayNodeDefinition $root)
{
$root->children()
->arrayNode('plugins')
Expand Down
18 changes: 13 additions & 5 deletions DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ private function configurePluginByName($name, Definition $definition, array $con
$definition->replaceArgument(0, new Reference($config['cookie_jar']));
break;
case 'decoder':
$definition->addArgument($config['use_content_encoding']);
$definition->addArgument([
'use_content_encoding' => $config['use_content_encoding'],
]);
break;
case 'history':
$definition->replaceArgument(0, new Reference($config['journal']));
Expand All @@ -157,16 +159,22 @@ private function configurePluginByName($name, Definition $definition, array $con
}
break;
case 'redirect':
$definition
->addArgument($config['preserve_header'])
->addArgument($config['use_default_for_multiple']);
$definition->addArgument([
'preserve_header' => $config['preserve_header'],
'use_default_for_multiple' => $config['use_default_for_multiple'],
]);
break;
case 'retry':
$definition->addArgument($config['retry']);
$definition->addArgument([
'retries' => $config['retry'],
]);
break;
case 'stopwatch':
$definition->replaceArgument(0, new Reference($config['stopwatch']));
break;

default:
throw new \InvalidArgumentException(sprintf('Internal exception: Plugin %s is not handled', $name));
}
}

Expand Down