<commit_before><?php

namespace JBen87\ParsleyBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
 * @author <NAME> <<EMAIL>>
 */
class ParsleyExtension extends Extension
{
    /**
     * @var string
     */
    private $name;

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

    /**
     * {@inheritdoc}
     *
     * @codeCoverageIgnore
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration($this->name);
        $config = $this->processConfiguration($configuration, $configs);

        $container->setParameter('jben87_parsley.global', $config['global']);
        $container->setParameter('jben87_parsley.trigger_event', $config['trigger_event']);

        $this->setDateTimePatternParameters($config, $container);

        $loader = new XmlFileLoader($container, new FileLocator(sprintf('%s/../Resources/config', __DIR__)));
        $loader->load('builder.xml');
        $loader->load('factory.xml');
        $loader->load('form.xml');
    }

    /**
     * {@inheritdoc}
     */
    public function getAlias()
    {
        return $this->name;
    }

    /**
     * @param array $config
     * @param ContainerBuilder $container
     */
    private function setDateTimePatternParameters(array $config, ContainerBuilder $container)
    {
        $locale = $container->getParameter('locale');
        $datePattern = '\d{4}-\d{2}-\d{2}';
        $timePattern = '\d{2}:\d{2}';
        $dateTimePattern = sprintf('%s %s', $datePattern, $timePattern);

        if (isset($config['date_time_pattern'][$locale])) {
            $dateTimePattern = $config['date_time_pattern'][$locale];
        }

        if (isset($config['date_pattern'][$locale])) {
            $datePattern = $config['date_pattern'][$locale];
        }

        if (isset($config['time_pattern'][$locale])) {
            $timePattern = $config['time_pattern'][$locale];
        }

        $container->setParameter('jben87_parsley.date_time_format', $dateTimePattern);
        $container->setParameter('jben87_parsley.date_format', $datePattern);
        $container->setParameter('jben87_parsley.time_format', $timePattern);
    }
}<commit_msg> Fix invalid container parameters name<commit_after><?php

namespace JBen87\ParsleyBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
 * @author <NAME> <<EMAIL>>
 */
class ParsleyExtension extends Extension
{
    /**
     * @var string
     */
    private $name;

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

    /**
     * {@inheritdoc}
     *
     * @codeCoverageIgnore
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration($this->name);
        $config = $this->processConfiguration($configuration, $configs);

        $container->setParameter('jben87_parsley.global', $config['global']);
        $container->setParameter('jben87_parsley.trigger_event', $config['trigger_event']);

        $this->setDateTimePatternParameters($config, $container);

        $loader = new XmlFileLoader($container, new FileLocator(sprintf('%s/../Resources/config', __DIR__)));
        $loader->load('builder.xml');
        $loader->load('factory.xml');
        $loader->load('form.xml');
    }

    /**
     * {@inheritdoc}
     */
    public function getAlias()
    {
        return $this->name;
    }

    /**
     * @param array $config
     * @param ContainerBuilder $container
     */
    private function setDateTimePatternParameters(array $config, ContainerBuilder $container)
    {
        $locale = $container->getParameter('locale');
        $datePattern = '\d{4}-\d{2}-\d{2}';
        $timePattern = '\d{2}:\d{2}';
        $dateTimePattern = sprintf('%s %s', $datePattern, $timePattern);

        if (isset($config['date_time_pattern'][$locale])) {
            $dateTimePattern = $config['date_time_pattern'][$locale];
        }

        if (isset($config['date_pattern'][$locale])) {
            $datePattern = $config['date_pattern'][$locale];
        }

        if (isset($config['time_pattern'][$locale])) {
            $timePattern = $config['time_pattern'][$locale];
        }

        $container->setParameter('jben87_parsley.date_time_pattern', $dateTimePattern);
        $container->setParameter('jben87_parsley.date_pattern', $datePattern);
        $container->setParameter('jben87_parsley.time_pattern', $timePattern);
    }
}
{'fraction_non_alphanumeric': 0.15579710144927536, 'fraction_numerical': 0.006843800322061192, 'mean_word_length': 3.147746243739566, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '1200422', 'n_tokens_mistral': 1455, 'n_tokens_neox': 1421, 'n_words': 217}