<commit_before><?php

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\RequestMatcher;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Form\FormContext;

/**
 * FrameworkExtension.
 *
 * @author <NAME> <<EMAIL>>
 */
class FrameworkExtension extends Extension
{
    public function configLoad(array $configs, ContainerBuilder $container)
    {
        foreach ($configs as $config) {
            $this->doConfigLoad($config, $container);
        }
    }

    /**
     * Loads the web configuration.
     *
     * @param array            $config    An array of configuration settings
     * @param ContainerBuilder $container A ContainerBuilder instance
     */
    protected function doConfigLoad(array $config, ContainerBuilder $container)
    {
        $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');

        if (!$container->hasDefinition('controller_resolver')) {
            $loader->load('web.xml');
        }

        if (!$container->hasDefinition('form.factory')) {
            $loader->load('form.xml');
        }

        if (isset($config['csrf_protection'])) {
            foreach (array('enabled', 'field_name', 'field-name', 'secret') as $key) {
                if (isset($config['csrf_protection'][$key])) {
                    $container->setParameter('form.csrf_protection.'.strtr($key, '-', '_'),
                            $config['csrf_protection'][$key]);
                }
            }
        }

        if (isset($config['i18n']) && $config['i18n']) {
            FormContext::setLocale(\Locale::get());
        }

        if (isset($config['ide'])) {
            switch ($config['ide']) {
                case 'textmate':
                    $pattern = 'txmt://open?url=file://%%f&line=%%l';
                    break;

                case 'macvim':
                    $pattern = 'mvim://open?url=file://%%f&line=%%l';
                    break;

                default:
                    // should be the link pattern then
                    $pattern = $config['ide'];
            }<commit_msg>[FrameworkBundle] added support for both csrf-protection and csrf_protection<commit_after><?php

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\RequestMatcher;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Form\FormContext;

/**
 * FrameworkExtension.
 *
 * @author <NAME> <<EMAIL>>
 */
class FrameworkExtension extends Extension
{
    public function configLoad(array $configs, ContainerBuilder $container)
    {
        foreach ($configs as $config) {
            $this->doConfigLoad($config, $container);
        }
    }

    /**
     * Loads the web configuration.
     *
     * @param array            $config    An array of configuration settings
     * @param ContainerBuilder $container A ContainerBuilder instance
     */
    protected function doConfigLoad(array $config, ContainerBuilder $container)
    {
        $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');

        if (!$container->hasDefinition('controller_resolver')) {
            $loader->load('web.xml');
        }

        if (!$container->hasDefinition('form.factory')) {
            $loader->load('form.xml');
        }

        if (isset($config['csrf-protection'])) {
            $config['csrf_protection'] = $config['csrf-protection'];
        }

        if (isset($config['csrf_protection'])) {
            foreach (array('enabled', 'field_name', 'field-name', 'secret') as $key) {
                if (isset($config['csrf_protection'][$key])) {
                    $container->setParameter('form.csrf_protection.'.strtr($key, '-', '_'),
                            $config['csrf_protection'][$key]);
                }
            }
        }

        if (isset($config['i18n']) && $config['i18n']) {
            FormContext::setLocale(\Locale::get());
        }

        if (isset($config['ide'])) {
            switch ($config['ide']) {
                case 'textmate':
                    $pattern = 'txmt://open?url=file://%%f&line=%%l';
                    break;

                case 'macvim':
                    $pattern = 'mvim://open?url=file://%%f&line=%%l';
                    break;

                default:
                    // should be the link pattern then
                    $pattern = $config['ide'];
            }
{'fraction_non_alphanumeric': 0.1347442680776014, 'fraction_numerical': 0.0014109347442680777, 'mean_word_length': 2.4558196221815964, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1795914', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1468, 'n_words': 305}