Skip to content

Commit

Permalink
Merge pull request #290 from odolbeau/avoid-deprecated-calls
Browse files Browse the repository at this point in the history
Avoid deprecated notice when using symfony/config > 4.2
  • Loading branch information
dbu committed Dec 13, 2018
2 parents 5da24de + 40e8657 commit 480b7fa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,12 @@

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

## Unreleased

### Fixed

- Fix deprecated notice when using symfony/config > 4.2

## 1.13.1 - 2018-11-28

### Fixed
Expand Down
37 changes: 29 additions & 8 deletions DependencyInjection/Configuration.php
Expand Up @@ -49,8 +49,13 @@ public function __construct($debug)
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('httplug');
$treeBuilder = new TreeBuilder('httplug');
// Keep compatibility with symfony/config < 4.2
if (!method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->root('httplug');
} else {
$rootNode = $treeBuilder->getRootNode();
}

$this->configureClients($rootNode);
$this->configureSharedPlugins($rootNode);
Expand Down Expand Up @@ -240,8 +245,13 @@ private function configureSharedPlugins(ArrayNodeDefinition $root)
*/
private function createClientPluginNode()
{
$builder = new TreeBuilder();
$node = $builder->root('plugins');
$treeBuilder = new TreeBuilder('plugins');
// Keep compatibility with symfony/config < 4.2
if (!method_exists($treeBuilder, 'getRootNode')) {
$node = $treeBuilder->root('plugins');
} else {
$node = $treeBuilder->getRootNode();
}

/** @var ArrayNodeDefinition $pluginList */
$pluginList = $node
Expand Down Expand Up @@ -514,8 +524,14 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA
*/
private function createAuthenticationPluginNode()
{
$builder = new TreeBuilder();
$node = $builder->root('authentication');
$treeBuilder = new TreeBuilder('authentication');
// Keep compatibility with symfony/config < 4.2
if (!method_exists($treeBuilder, 'getRootNode')) {
$node = $treeBuilder->root('authentication');
} else {
$node = $treeBuilder->getRootNode();
}

$node
->useAttributeAsKey('name')
->prototype('array')
Expand Down Expand Up @@ -605,9 +621,14 @@ private function validateAuthenticationType(array $expected, array $actual, $aut
*/
private function createCachePluginNode()
{
$builder = new TreeBuilder();
$builder = new TreeBuilder('config');
// Keep compatibility with symfony/config < 4.2
if (!method_exists($builder, 'getRootNode')) {
$config = $builder->root('config');
} else {
$config = $builder->getRootNode();
}

$config = $builder->root('config');
$config
->fixXmlConfig('method')
->fixXmlConfig('respect_response_cache_directive')
Expand Down

0 comments on commit 480b7fa

Please sign in to comment.