<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\Provider;

use Silex\Application;
use Silex\ServiceProviderInterface;

use Symfony\Bridge\Twig\Extension\RoutingExtension as TwigRoutingExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension as TwigTranslationExtension;
use Symfony\Bridge\Twig\Extension\FormExtension as TwigFormExtension;

/**
 * Twig Provider.
 *
 * @author <NAME> <<EMAIL>>
 */
class TwigServiceProvider implements ServiceProviderInterface
{
    public function register(Application $app)
    {
        $app['twig'] = $app->share(function () use ($app) {
            $app['twig.options'] = array_replace(
                array(
                    'charset'          => $app['charset'],
                    'debug'            => $app['debug'],
                    'strict_variables' => $app['debug'],
                ),
                isset($app['twig.options']) ? $app['twig.options'] : array()
            );

            $twig = new \Twig_Environment($app['twig.loader'], $app['twig.options']);
            $twig->addGlobal('app', $app);
            $twig->addExtension(new TwigCoreExtension());

            if (isset($app['symfony_bridges'])) {
                if (isset($app['url_generator'])) {
                    $twig->addExtension(new TwigRoutingExtension($app['url_generator']));
                }

                if (isset($app['translator'])) {
                    $twig->addExtension(new TwigTranslationExtension($app['translator']));
                }

                if (isset($app['form.factory'])) {
                    $twig->addExtension(new TwigFormExtension(array('form_div_layout.html.twig')));
                }
            }

            if (isset($app['twig.configure'])) {
                $app['twig.configure']($twig);
            }

            return $twig;
        });

        $app['twig.loader.filesystem'] = $app->share(function () use ($app) {<commit_msg>load default form_div_layout.html.twig when using form and twig service providers<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\Provider;

use Silex\Application;
use Silex\ServiceProviderInterface;

use Symfony\Bridge\Twig\Extension\RoutingExtension as TwigRoutingExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension as TwigTranslationExtension;
use Symfony\Bridge\Twig\Extension\FormExtension as TwigFormExtension;

/**
 * Twig Provider.
 *
 * @author <NAME> <<EMAIL>>
 */
class TwigServiceProvider implements ServiceProviderInterface
{
    public function register(Application $app)
    {
        $app['twig'] = $app->share(function () use ($app) {
            $app['twig.options'] = array_replace(
                array(
                    'charset'          => $app['charset'],
                    'debug'            => $app['debug'],
                    'strict_variables' => $app['debug'],
                ),
                isset($app['twig.options']) ? $app['twig.options'] : array()
            );

            $twig = new \Twig_Environment($app['twig.loader'], $app['twig.options']);
            $twig->addGlobal('app', $app);
            $twig->addExtension(new TwigCoreExtension());

            if (isset($app['symfony_bridges'])) {
                if (isset($app['url_generator'])) {
                    $twig->addExtension(new TwigRoutingExtension($app['url_generator']));
                }

                if (isset($app['translator'])) {
                    $twig->addExtension(new TwigTranslationExtension($app['translator']));
                }

                if (isset($app['form.factory'])) {
                    $twig->addExtension(new TwigFormExtension(array('form_div_layout.html.twig')));

                    // add loader for form_div_layout.html.twig
                    $reflected = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
                    $path = dirname($reflected->getFileName()).'/../Resources/views/Form';
                    $app['twig.loader']->addLoader(new \Twig_Loader_Filesystem($path));
                }
            }

            if (isset($app['twig.configure'])) {
                $app['twig.configure']($twig);
            }

            return $twig;
        });

        $app['twig.loader.filesystem'] = $app->share(function () use ($app) {
{'fraction_non_alphanumeric': 0.14506437768240343, 'fraction_numerical': 0.0, 'mean_word_length': 2.1946538725154214, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 37, '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': '4543682', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1267, 'n_words': 238}