<?php

namespace AlterPHP\EasyAdminExtensionBundle\DependencyInjection;

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

/**
 * This is the class that validates and merges configuration from your app/config files.
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder('easy_admin_extension');

        $treeBuilder
            ->getRootNode()
            ->children()
                ->arrayNode('custom_form_types')
                    ->useAttributeAsKey('short_name')
                    ->prototype('scalar')
                        ->validate()
                            ->ifTrue(function ($v) {
                                return !\class_exists($v);
                            })
                                ->thenInvalid('Class %s for custom type does not exist !')
                        ->end()
                    ->end()
                ->end()
                ->scalarNode('minimum_role')
                    ->defaultNull()
                ->end()
                ->arrayNode('embedded_list')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('open_new_tab')
                            ->defaultTrue()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;

        return $treeBuilder;
    }
}

<?php

namespace AlterPHP\EasyAdminExtensionBundle\DependencyInjection;

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

/**
 * This is the class that validates and merges configuration from your app/config files.
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('easy_admin_extension');

        $rootNode
            ->children()
                ->arrayNode('custom_form_types')
                    ->useAttributeAsKey('short_name')
                    ->prototype('scalar')
                        ->validate()
                            ->ifTrue(function ($v) {
                                return !\class_exists($v);
                            })
                                ->thenInvalid('Class %s for custom type does not exist !')
                        ->end()
                    ->end()
                ->end()
                ->scalarNode('minimum_role')
                    ->defaultNull()
                ->end()
                ->arrayNode('embedded_list')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('open_new_tab')
                            ->defaultTrue()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;

        return $treeBuilder;
    }
}

Revert "Remove Sf4.2 deprecation on TreeBuilder constructor"
Revert "Remove Sf4.2 deprecation on TreeBuilder constructor"

This reverts commit 803a5a2bcfa827db60f2bd0b55f144aa896adfb5.
