Skip to content

Fix A tree builder without a root node deprecation in Symfony 4.2  #9

Description

@evs-xsarus

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

The "Symfony\Component\Config\Definition\Builder\TreeBuilder::root()" method called for the "lexik_data_layer" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.

See https://github.com/lexik/LexikDataLayerBundle/blob/master/DependencyInjection/Configuration.php

Fix would be:

<?php

namespace Lexik\Bundle\DataLayerBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * Configuration
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder('lexik_data_layer');
        // BC layer for symfony/config < 4.2
        $rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('apy_breadcrumb_trail');

        return $treeBuilder;
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions