Skip to content

The package does not work with Symfony 4.0 #32

@ignasdamunskis

Description

@ignasdamunskis

When I upgraded to Symfony 4.0, I was met with an error:

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\UndefinedMethodException: Attempted to call an undefined method named "getRootNode" of class "Symfony\Component\Config\Definition\Builder\TreeBuilder". in /var/www/html/vendor/bentools/webpush-bundle/src/DependencyInjection/Configuration.php:18

I found out that in BenTools\WebPushBundle\DependencyInjection::getConfigTreeBuilder()

if (Kernel::MAJOR_VERSION < 4) {
    $treeBuilder = new TreeBuilder();
    $rootNode = $treeBuilder->root('bentools_webpush');
} else {
    $treeBuilder = new TreeBuilder('bentools_webpush');
    $rootNode = $treeBuilder->getRootNode();
}

I noticed that other packages that are not failing are basically checking if method exists before calling it (i.e doctrine):

$treeBuilder = new TreeBuilder('doctrine');

if (method_exists($treeBuilder, 'getRootNode')) {
    $rootNode = $treeBuilder->getRootNode();
} else {
    // BC layer for symfony/config 4.1 and older
    $rootNode = $treeBuilder->root('doctrine');
}

Notice the comment, seems thatgetRootNode method does not exist in <4.2. Could we add a support for it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions