Skip to content

Commit

Permalink
fix: TreeBuilder (#72)
Browse files Browse the repository at this point in the history
* fix: SF5 compatibility

* refactor: check for getRootNode method existence

* fix: test if getRootNode exits

* fix(review): remove unused use statement

Co-authored-by: Oliver THEBAULT <[email protected]>
  • Loading branch information
SelviA and Oliboy50 authored Jul 10, 2020
1 parent a9f9f46 commit 4e7df16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"require-dev": {
"atoum/atoum": "^2.8|^3.0",
"symfony/symfony": "^3.4 || ^4.0",
"symfony/symfony": "^3.4 || ^4.0 || ^5.0",
"m6web/coke" : "~1.2",
"m6web/symfony2-coding-standard" : "~1.2"
},
Expand Down
10 changes: 8 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('m6_statsd');
// symfony/config >= 4.2.0
if (\method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('m6_statsd');
$rootNode = $treeBuilder->getRootNode();
} else {
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('m6_statsd');
}

$this->addServersSection($rootNode);
$this->addClientsSection($rootNode);
Expand Down

0 comments on commit 4e7df16

Please sign in to comment.