<commit_before><?php

namespace CleverAge\EAVManager\ProcessBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\NodeBuilder;
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
{
    /** @var string */
    protected $root;

    /**
     * @param string $root
     */
    public function __construct($root = 'clever_age_eav_manager_process')
    {
        $this->root = $root;
    }

    /**
     * {@inheritdoc}
     *
     * @throws \RuntimeException
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root($this->root);
        $definition = $rootNode
            ->children();

        // Process list
        $processListDefinition = $definition->arrayNode('process_list')->useAttributeAsKey('code')
            ->prototype('array')->performNoDeepMerging()->cannotBeOverwritten()
            ->children();

        $this->appendProcessConfigDefinition($processListDefinition);

        $processListDefinition->end()
            ->end()
            ->end();

        // Transformer list
        $transformerListDefinition = $definition->arrayNode('transformer_list')->useAttributeAsKey('code')
            ->prototype('array')->performNoDeepMerging()->cannotBeOverwritten()
            ->children();

        $this->appendTransformerConfigDefinition($transformerListDefinition);

        $transformerListDefinition->end()
            ->end()
            ->end();

        $definition->end();

        return $treeBuilder;
    }

    /**
     * @param NodeBuilder $definition
     */
    protected function appendProcessConfigDefinition(NodeBuilder $definition)
    {
        $definition->scalarNode('service')->defaultValue('@eavmanager.process_manager')->end()
            // TODO use more accurate modelisation with arrayNode ?
            ->variableNode('subprocess')->end();
    }

    /**
     * @param NodeBuilder $definition
     */
    protected function appendTransformerConfigDefinition(NodeBuilder $definition)
    {
        $transformerConfigDefintion = $definition
            ->scalarNode('service')->defaultValue('@eavmanager.transformer_manager')->end()
            ->arrayNode('mapping')->isRequired()
            ->prototype('array')->performNoDeepMerging()->cannotBeOverwritten()
            ->children();

        $transformerConfigDefintion
            ->scalarNode('code')->end()
            ->scalarNode('constant')->end()
            ->variableNode('transformer')->end();

        $definition
            ->end()<commit_msg>Draft of most export<commit_after><?php

namespace CleverAge\EAVManager\ProcessBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\NodeBuilder;
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
{
    /** @var string */
    protected $root;

    /**
     * @param string $root
     */
    public function __construct($root = 'clever_age_eav_manager_process')
    {
        $this->root = $root;
    }

    /**
     * {@inheritdoc}
     *
     * @throws \RuntimeException
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root($this->root);
        $definition = $rootNode
            ->children();

        // Process list
        $processListDefinition = $definition->arrayNode('process_list')->useAttributeAsKey('code')
            ->prototype('array')->performNoDeepMerging()->cannotBeOverwritten()
            ->children();

        $this->appendProcessConfigDefinition($processListDefinition);

        $processListDefinition->end()
            ->end()
            ->end();

        // Transformer list
        $transformerListDefinition = $definition->arrayNode('transformer_list')->useAttributeAsKey('code')
            ->prototype('array')->performNoDeepMerging()->cannotBeOverwritten()
            ->children();

        $this->appendTransformerConfigDefinition($transformerListDefinition);

        $transformerListDefinition->end()
            ->end()
            ->end();

        $definition->end();

        return $treeBuilder;
    }

    /**
     * @param NodeBuilder $definition
     */
    protected function appendProcessConfigDefinition(NodeBuilder $definition)
    {
        $definition->scalarNode('service')->defaultValue('@eavmanager.process_manager')->end()
            // TODO use more accurate modelisation with arrayNode ?
            ->variableNode('subprocess')->end();
    }

    /**
     * @param NodeBuilder $definition
     */
    protected function appendTransformerConfigDefinition(NodeBuilder $definition)
    {
        $transformerConfigDefintion = $definition
            ->scalarNode('service')->defaultValue('@eavmanager.transformer_manager')->end()
            ->arrayNode('mapping')->isRequired()
            ->prototype('array')->performNoDeepMerging()->cannotBeOverwritten()
            ->children();

        $transformerConfigDefintion
            ->variableNode('code')->end()
            ->scalarNode('constant')->end()
            ->variableNode('transformer')->end();

        $definition
            ->end()
{'fraction_non_alphanumeric': 0.13441884635371557, 'fraction_numerical': 0.0, 'mean_word_length': 2.7738562091503267, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7385811', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1422, 'n_words': 236}