<commit_before><?php

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

namespace WouterJ\Bundleless;

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
 * A base kernel that automatically registers an App virtual bundle.
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class AppFocusedKernel extends Kernel
{
    /**
     * The path to the directory containing the application code.
     *
     * This defaults to src/ in the root of the application
     */
    protected $appPath;

    /**
     * The namespace prefix for the application code.
     *
     * This defaults to an empty string, meaning no prefix.
     */
    protected $appNamespace = '';

    public function __construct($environment, $debug)
    {
        parent::__construct($environment, $debug);

        if (!$this->appPath) {
            $this->appPath = realpath($this->getRootDir().'/../src');
        } else {
            $this->appPath = str_replace('%kernel.root_dir%', $this->getRootDir(), $this->appPath);
        }
    }

    protected function initializeBundles()
    {
        parent::initializeBundles();

        $this->bundles['App'] = $bundle = new VirtualBundle('App', $this->appPath, $this->appNamespace);
        $this->bundleMap['App'] = array($bundle);
    }
    
    protected function prepareContainer(ContainerBuilder $container)
    {
        parent::prepareContainer($container);

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

        foreach ($bundles as $name => $fqcn) {
            switch ($name) {
                case 'DoctrineBundle':
                    $container->loadFromExtension('doctrine', array(
                        'orm' => array(
                            'mappings' => array(
                                'App' => array(
                                    'type' => 'annotation',
                                    'prefix' => $this->appNamespace ? $this->appNamespace.'\Entity' : 'Entity',
                                    'dir' => $this->appPath.'/Entity',
                                ),
                            ),
                        ),
                    ));
                    break;
            }
        }

        $container->setParameter('controller_name_converter.class', 'WouterJ\Bundleless\Controller\ControllerNameParser');
    }
}
<commit_msg>Made Kernel more simple and require App\ namespace<commit_after><?php

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

namespace WouterJ\Bundleless;

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
 * A base kernel that automatically registers an App virtual bundle.
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class AppFocusedKernel extends Kernel
{
    protected function getAppBundle()
    {
        return new VirtualBundle('App', realpath($this->getRootDir().'/../src'), 'App');
    }

    protected function initializeBundles()
    {
        parent::initializeBundles();

        $this->bundles['App'] = $bundle = $this->getAppBundle();
        $this->bundleMap['App'] = array($bundle);
    }
    
    protected function prepareContainer(ContainerBuilder $container)
    {
        parent::prepareContainer($container);

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

        foreach ($bundles as $name => $fqcn) {
            switch ($name) {
                case 'DoctrineBundle':
                    $container->loadFromExtension('doctrine', array(
                        'orm' => array(
                            'mappings' => array(
                                'App' => array(
                                    'type' => 'annotation',
                                    'prefix' => $this->appNamespace ? $this->appNamespace.'\Entity' : 'Entity',
                                    'dir' => $this->appPath.'/Entity',
                                ),
                            ),
                        ),
                    ));
                    break;
            }
        }

        $container->setParameter('controller_name_converter.class', 'WouterJ\Bundleless\Controller\ControllerNameParser');
    }
}

{'fraction_non_alphanumeric': 0.12433978873239436, 'fraction_numerical': 0.0017605633802816902, 'mean_word_length': 1.8513174404015056, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4637479', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1123, 'n_words': 274}