<commit_before><?php

namespace AlphaLemon\ThemeEngineBundle\Command\Generate;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Sensio\Bundle\GeneratorBundle\Command\Validators;
use AlphaLemon\ThemeEngineBundle\Core\Generator\AlAppThemeGenerator;

class GenerateAppThemeBundleCommand extends BaseGenerateBundle
{
    protected function configure()
    {
        $this
            ->setName('alphalemon:generate:app-theme')
            ->setDescription('Generate a App-Block bundle')
            ->setDefinition(array(
                new InputOption('namespace', '', InputOption::VALUE_REQUIRED, 'The namespace of the bundle to create'),
                new InputOption('dir', '', InputOption::VALUE_REQUIRED, 'The directory where to create the bundle'),
                new InputOption('bundle-name', '', InputOption::VALUE_REQUIRED, 'The optional bundle name'),
                new InputOption('format', '', InputOption::VALUE_REQUIRED, 'Do nothing but mandatory for extend', 'annotation'),
                new InputOption('structure', '', InputOption::VALUE_NONE, 'Whether to generate the whole directory structure'),
                new InputOption('strict', '', InputOption::VALUE_NONE, 'Forces the bundle namespace to be compatible as distributable App-Block'),
            ));
    }

    protected function checkStrictNamespace($namespace)
    {
        if (preg_match('/^AlphaLemon\\\\Theme\\\\[\w]+ThemeBundle/', $namespace) == false) {
            throw new \RuntimeException('A strict AlphaLemon App-Theme namespace must start with AlphaLemon\Theme');
        }
    }

    protected function getGeneratorExtraOptions(InputInterface $input)
    {
        return array(
            'strict' => $input->getOption('strict'),
        );
    }

    protected function getGenerator()
    {
        $kernel = $this->getContainer()->get('kernel');
        $bundlePath = $kernel->locateResource('@SensioGeneratorBundle');

        return new AlAppThemeGenerator($this->getContainer()->get('filesystem'), $bundlePath.'/Resources/skeleton/bundle');
    }<commit_msg>fixed to instantiate the generator only when needed<commit_after><?php

namespace AlphaLemon\ThemeEngineBundle\Command\Generate;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Sensio\Bundle\GeneratorBundle\Command\Validators;
use AlphaLemon\ThemeEngineBundle\Core\Generator\AlAppThemeGenerator;

class GenerateAppThemeBundleCommand extends BaseGenerateBundle
{
    protected function configure()
    {
        $this
            ->setName('alphalemon:generate:app-theme')
            ->setDescription('Generate a App-Block bundle')
            ->setDefinition(array(
                new InputOption('namespace', '', InputOption::VALUE_REQUIRED, 'The namespace of the bundle to create'),
                new InputOption('dir', '', InputOption::VALUE_REQUIRED, 'The directory where to create the bundle'),
                new InputOption('bundle-name', '', InputOption::VALUE_REQUIRED, 'The optional bundle name'),
                new InputOption('format', '', InputOption::VALUE_REQUIRED, 'Do nothing but mandatory for extend', 'annotation'),
                new InputOption('structure', '', InputOption::VALUE_NONE, 'Whether to generate the whole directory structure'),
                new InputOption('strict', '', InputOption::VALUE_NONE, 'Forces the bundle namespace to be compatible as distributable App-Block'),
            ));
    }

    protected function checkStrictNamespace($namespace)
    {
        if (preg_match('/^AlphaLemon\\\\Theme\\\\[\w]+ThemeBundle/', $namespace) == false) {
            throw new \RuntimeException('A strict AlphaLemon App-Theme namespace must start with AlphaLemon\Theme and the bundle must be suffixed as ThemeBundle');
        }
    }

    protected function getGeneratorExtraOptions(InputInterface $input)
    {
        return array(
            'strict' => $input->getOption('strict'),
        );
    }

    protected function getGenerator()
    {
        if (null === $this->generator) {
            $kernel = $this->getContainer()->get('kernel');
            $bundlePath = $kernel->locateResource('@SensioGeneratorBundle');

            return new AlAppThemeGenerator($this->getContainer()->get('filesystem'), $bundlePath.'/Resources/skeleton/bundle');
        }

        return $this->generator;
    }
{'fraction_non_alphanumeric': 0.11910013233348037, 'fraction_numerical': 0.0, 'mean_word_length': 3.373191899710704, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2396369', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1116, 'n_words': 268}