Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The package does not work with Symfony 4.0 #32

Open
ignasdamunskis opened this issue Feb 26, 2022 · 1 comment
Open

The package does not work with Symfony 4.0 #32

ignasdamunskis opened this issue Feb 26, 2022 · 1 comment

Comments

@ignasdamunskis
Copy link

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?

@bpolaszek
Copy link
Owner

Hello there,

Thanks for your feedback.

Even though I'm not in favor of supporting old versions like this, feel free to submit a PR if this doesn't harm.

Thank you,
Ben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants