Skip to content

Commit

Permalink
Use TreeBuilder::getRootNode() instead of TreeBuilder::root() when po…
Browse files Browse the repository at this point in the history
…ssible
  • Loading branch information
Oliboy50 committed Feb 18, 2019
1 parent c06f1f1 commit eb72450
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/DependencyInjection/CommandBusConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder($this->alias);

$rootNode = $treeBuilder->root($this->alias);
if (method_exists($treeBuilder, 'getRootNode')) {
// Symfony 4.2 +
$rootNode = $treeBuilder->getRootNode();
} else {
// Symfony 4.1 and below
$rootNode = $treeBuilder->root($this->alias);
}

$rootNode
->addDefaultsIfNotSet()
->children()
Expand Down
8 changes: 7 additions & 1 deletion src/DependencyInjection/DoctrineOrmBridgeConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder($this->alias);

$rootNode = $treeBuilder->root($this->alias);
if (method_exists($treeBuilder, 'getRootNode')) {
// Symfony 4.2 +
$rootNode = $treeBuilder->getRootNode();
} else {
// Symfony 4.1 and below
$rootNode = $treeBuilder->root($this->alias);
}

$rootNode
->addDefaultsIfNotSet()
Expand Down
9 changes: 8 additions & 1 deletion src/DependencyInjection/EventBusConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder($this->alias);

$rootNode = $treeBuilder->root($this->alias);
if (method_exists($treeBuilder, 'getRootNode')) {
// Symfony 4.2 +
$rootNode = $treeBuilder->getRootNode();
} else {
// Symfony 4.1 and below
$rootNode = $treeBuilder->root($this->alias);
}

$rootNode
->addDefaultsIfNotSet()
->children()
Expand Down

0 comments on commit eb72450

Please sign in to comment.