<commit_before><?php

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

namespace Sonata\PageBundle\DependencyInjection;

use Sonata\EasyExtendsBundle\Mapper\DoctrineCollector;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
 * PageExtension.
 *
 * @author     <NAME> <<EMAIL>>
 */
class SonataPageExtension extends Extension
{
    /**
     * {@inheritdoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $processor = new Processor();
        $configuration = new Configuration();
        $config = $processor->processConfiguration($configuration, $configs);

        $bundles = $container->getParameter('kernel.bundles');

        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('page.xml');

        if (isset($bundles['FOSRestBundle']) && isset($bundles['NelmioApiDocBundle'])) {
            $loader->load('serializer.xml');

            $loader->load('api_controllers.xml');
            $loader->load('api_form.xml');
        }

        if (isset($bundles['SonataAdminBundle'])) {
            $loader->load('admin.xml');

            if (!$config['direct_publication']) {
                $container->removeDefinition('sonata.page.admin.extension.snapshot');
            }
        }

        $loader->load('block.xml');
        $loader->load('orm.xml');
        $loader->load('form.xml');
        $loader->load('cache.xml');
        $loader->load('twig.xml');
        $loader->load('http_kernel.xml');
        $loader->load('consumer.xml');
        $loader->load('validators.xml');

        $this->configureMultisite($container, $config);
        $this->configureCache($container, $config);
        $this->configureTemplates($container, $config);
        $this->configureTemplatesAdmin($container, $config);
        $this->configureExceptions($container, $config);
        $this->configurePageDefaults($container, $config);
        $this->configurePageServices($container, $config);
        $this->configureClassesToCompile();

        $container->setParameter('sonata.page.assets', $config['assets']);
        $container->setParameter('sonata.page.slugify_service', $config['slugify_service']);

        $container->setParameter('sonata.page.is_inline_edition_on', $config['is_inline_edition_on']);
        $container->setParameter('sonata.page.hide_disabled_blocks', $config['hide_disabled_blocks']);
        $container->getDefinition('sonata.page.decorator_strategy')
            ->replaceArgument(0, $config['ignore_routes'])
            ->replaceArgument(1, $config['ignore_route_patterns'])
            ->replaceArgument(2, $config['ignore_uri_patterns']);

        $this->registerDoctrineMapping($config);
        $this->registerParameters($container, $config);
    }<commit_msg>Configure admin template only if AdminBundle is present (#681)<commit_after><?php

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

namespace Sonata\PageBundle\DependencyInjection;

use Sonata\EasyExtendsBundle\Mapper\DoctrineCollector;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
 * PageExtension.
 *
 * @author     <NAME> <<EMAIL>>
 */
class SonataPageExtension extends Extension
{
    /**
     * {@inheritdoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $processor = new Processor();
        $configuration = new Configuration();
        $config = $processor->processConfiguration($configuration, $configs);

        $bundles = $container->getParameter('kernel.bundles');

        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('page.xml');

        if (isset($bundles['FOSRestBundle']) && isset($bundles['NelmioApiDocBundle'])) {
            $loader->load('serializer.xml');

            $loader->load('api_controllers.xml');
            $loader->load('api_form.xml');
        }

        if (isset($bundles['SonataAdminBundle'])) {
            $loader->load('admin.xml');

            if (!$config['direct_publication']) {
                $container->removeDefinition('sonata.page.admin.extension.snapshot');
            }

            $this->configureTemplatesAdmin($container, $config);
        }

        $loader->load('block.xml');
        $loader->load('orm.xml');
        $loader->load('form.xml');
        $loader->load('cache.xml');
        $loader->load('twig.xml');
        $loader->load('http_kernel.xml');
        $loader->load('consumer.xml');
        $loader->load('validators.xml');

        $this->configureMultisite($container, $config);
        $this->configureCache($container, $config);
        $this->configureTemplates($container, $config);
        $this->configureExceptions($container, $config);
        $this->configurePageDefaults($container, $config);
        $this->configurePageServices($container, $config);
        $this->configureClassesToCompile();

        $container->setParameter('sonata.page.assets', $config['assets']);
        $container->setParameter('sonata.page.slugify_service', $config['slugify_service']);

        $container->setParameter('sonata.page.is_inline_edition_on', $config['is_inline_edition_on']);
        $container->setParameter('sonata.page.hide_disabled_blocks', $config['hide_disabled_blocks']);
        $container->getDefinition('sonata.page.decorator_strategy')
            ->replaceArgument(0, $config['ignore_routes'])
            ->replaceArgument(1, $config['ignore_route_patterns'])
            ->replaceArgument(2, $config['ignore_uri_patterns']);

        $this->registerDoctrineMapping($config);
        $this->registerParameters($container, $config);
    }
{'fraction_non_alphanumeric': 0.1518285371702638, 'fraction_numerical': 0.0013489208633093526, 'mean_word_length': 3.621191135734072, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 26}, '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': '6428310', 'n_tokens_mistral': 1837, 'n_tokens_neox': 1806, 'n_words': 278}