<commit_before><?php

namespace EdRush\Bundle\ExtbaserBundle\Command;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use EdRush\Extbaser\ExtbaseExporter;

/**
 * Export an existing database schema to a Extbase project file (ExtensionBuilder.json).
 *
 * @author <NAME> <<EMAIL>>
 */
class ExportExtbaseCommand extends ContainerAwareCommand
{
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        $this
            ->setName('extbaser:export')
            ->setDescription('Export an existing Symfony database schema to a TYPO3 Extbase Extension')

            ->addArgument('extension-key', InputArgument::REQUIRED, 'The target TYPO3 Extension key')

            ->addOption('path', null, InputOption::VALUE_OPTIONAL, 'The path to export the extension to', $this->getContainer()->getParameter('kernel.cache_dir'))
            ->addOption('em', null, InputOption::VALUE_OPTIONAL)
        ;

        foreach (\EdRush\Extbaser\Command\ExportExtbaseCommand::getDefaultInputOptions() as $inputOption) {
            $this->getDefinition()->addOption($inputOption);
        }
    }

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->getContainer()->get('doctrine')->getManager($input->getOption('em'));

        $emName = $input->getOption('em');
        $emName = $emName ? $emName : 'default';

        $cmf = new DisconnectedClassMetadataFactory();
        $cmf->setEntityManager($em);

        $exporter = new ExtbaseExporter($cmf);
        $exporter->setExtensionKey($input->getArgument('extension-key'));
        $exporter->setPath($input->getOption('path'));
        \EdRush\Extbaser\Command\ExportExtbaseCommand::mapDefaultInputOptions($exporter, $input);

        $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));

        $result = $exporter->exportJson();

        foreach ($exporter->getLogs() as $log) {
            $output->writeln($log);
        }<commit_msg>Hotfix <commit_after><?php

namespace EdRush\Bundle\ExtbaserBundle\Command;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use EdRush\Extbaser\ExtbaseExporter;

/**
 * Export an existing database schema to a Extbase project file (ExtensionBuilder.json).
 *
 * @author <NAME> <<EMAIL>>
 */
class ExportExtbaseCommand extends ContainerAwareCommand
{
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        $this
            ->setName('extbaser:export')
            ->setDescription('Export an existing Symfony database schema to a TYPO3 Extbase Extension')

            ->addArgument('extension-key', InputArgument::REQUIRED, 'The target TYPO3 Extension key')

            ->addOption('path', null, InputOption::VALUE_OPTIONAL)
            ->addOption('em', null, InputOption::VALUE_OPTIONAL)
        ;

        foreach (\EdRush\Extbaser\Command\ExportExtbaseCommand::getDefaultInputOptions() as $inputOption) {
            $this->getDefinition()->addOption($inputOption);
        }
    }

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->getContainer()->get('doctrine')->getManager($input->getOption('em'));
        $path = $input->getOption('path') ? $input->getOption('path') : $this->getContainer()->getParameter("kernel.cache_dir");

        $emName = $input->getOption('em');
        $emName = $emName ? $emName : 'default';

        $cmf = new DisconnectedClassMetadataFactory();
        $cmf->setEntityManager($em);

        $exporter = new ExtbaseExporter($cmf);
        $exporter->setExtensionKey($input->getArgument('extension-key'));
        $exporter->setPath($path);
        \EdRush\Extbaser\Command\ExportExtbaseCommand::mapDefaultInputOptions($exporter, $input);

        $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));

        $result = $exporter->exportJson();

        foreach ($exporter->getLogs() as $log) {
            $output->writeln($log);
        }
{'fraction_non_alphanumeric': 0.1402269321344466, 'fraction_numerical': 0.0008563476771569257, 'mean_word_length': 3.6074950690335306, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 60, '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': '4646586', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1305, 'n_words': 235}