Fix: Deprecation: A tree builder without a root node is deprecated since symfony 4.2 (#1457)

* Fix: Deprecation: A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.

* Fix: Deprecation: A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.
This commit is contained in:
mantis 2019-01-25 17:17:45 +00:00 committed by Guilhem N
parent edb54a1551
commit 7a5c8a2e0d

View File

@ -18,9 +18,16 @@ final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$treeBuilder
->root('nelmio_api_doc')
$treeBuilder = new TreeBuilder('nelmio_api_doc');
if (method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
// symfony < 4.2 support
$rootNode = $treeBuilder->root('nelmio_api_doc');
}
$rootNode
->beforeNormalization()
->ifTrue(function ($v) {
return !isset($v['areas']) && isset($v['routes']);