<commit_before><?php

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

namespace Silex\Extension;

use Silex\Application;
use Silex\ExtensionInterface;
use Symfony\Component\HttpFoundation\File\TemporaryStorage;
use Symfony\Component\Form\CsrfProvider\DefaultCsrfProvider;
use Symfony\Component\Form\Type\Loader\DefaultTypeLoader;
use Symfony\Component\Form\FormFactory;

class FormExtension implements ExtensionInterface
{
    public function register(Application $app)
    {
        $app['form.csrf.secret'] = '12345';
        $app['form.storage.secret'] = 'abcdef';

        $app['form.factory'] = $app->share(function () use ($app) {
            return new FormFactory($app['form.type_loader']);
        });

        $app['form.type_loader'] = $app->share(function () use ($app) {
            if (!isset($app['validator'])) {
                throw new \RuntimeException(sprintf('The FormExtension needs the ValidationExtension to be registered.'));
            }

            return new DefaultTypeLoader($app['validator'], $app['form.csrf.provider'], $app['form.storage']);
        });

        $app['form.csrf.provider'] = $app->share(function () use ($app) {
            return new DefaultCsrfProvider($app['form.csrf.secret']);
        });

        $app['form.storage'] = $app->share(function () use ($app) {
            return new TemporaryStorage($app['form.storage.secret']);
        });

        if (isset($app['form.class_path'])) {
            $app['autoloader']->registerNamespace('Symfony\\Component\\Form', $app['form.class_path']);<commit_msg>updated FormExtension to work with the latest Symfony version<commit_after><?php

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

namespace Silex\Extension;

use Silex\Application;
use Silex\ExtensionInterface;
use Symfony\Component\HttpFoundation\File\TemporaryStorage;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;

class FormExtension implements ExtensionInterface
{
    public function register(Application $app)
    {
        $app['form.csrf_secret'] = '12345';
        $app['form.storage_secret'] = 'abcdef';

        $app['form.factory'] = $app->share(function () use ($app) {
            $extensions = array(
                new CoreExtension($app['form.storage']),
                new CsrfExtension($app['form.csrf_provider']),
            );

            if (isset($app['validator'])) {
                $extensions[] = new ValidatorExtension($app['validator']);
            }

            return new FormFactory($extensions);
        });

        $app['form.csrf_provider'] = $app->share(function () use ($app) {
            return new DefaultCsrfProvider($app['form.csrf_secret']);
        });

        $app['form.storage'] = $app->share(function () use ($app) {
            return new TemporaryStorage($app['form.storage_secret']);
        });

        if (isset($app['form.class_path'])) {
            $app['autoloader']->registerNamespace('Symfony\\Component\\Form', $app['form.class_path']);
{'fraction_non_alphanumeric': 0.1468511719853149, 'fraction_numerical': 0.002824060999717594, 'mean_word_length': 3.272617611580217, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, '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': '7043050', 'n_tokens_mistral': 1009, 'n_tokens_neox': 981, 'n_words': 207}