Newscoop\PluginGeneratorBundle\Command\GeneratePluginBundleCommand::execute PHP Метод

execute() защищенный Метод

См. также: Command
protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $dialog = $this->getDialogHelper();
        if ($input->isInteractive()) {
            if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
                $output->writeln('<error>Command aborted</error>');
                return 1;
            }
        }
        foreach (array('plugin-name', 'namespace', 'dir') as $option) {
            if (null === $input->getOption($option)) {
                throw new \RuntimeException(sprintf('The "%s" option must be provided.', $option));
            }
        }
        // validate the namespace
        $vendor = Validators::validateVendor($input->getOption('vendor'));
        $pluginName = Validators::validatePluginName($input->getOption('plugin-name'));
        $namespace = Validators::validateBundleNamespace($input->getOption('namespace'), false);
        if (!($bundle = $input->getOption('bundle-name'))) {
            $bundle = strtr($namespace, array('\\' => ''));
        }
        $bundle = Validators::validateBundleName($bundle);
        $dir = Validators::validateTargetDir($input->getOption('dir'));
        if (null === $input->getOption('format')) {
            $input->setOption('format', 'annotation');
        }
        $format = Validators::validateFormat($input->getOption('format'));
        $structure = $input->getOption('structure');
        $admin = $input->getOption('admin');
        $zip = $input->getOption('zip');
        $dialog->writeSection($output, 'Bundle generation');
        if (!$this->getContainer()->get('filesystem')->isAbsolutePath($dir)) {
            $dir = getcwd() . '/' . $dir;
        }
        $generator = $this->getGenerator();
        $generator->generate($vendor, $pluginName, $namespace, $bundle, $dir, $format, $structure, $admin, $zip);
        $output->writeln('Generating the bundle code: <info>OK</info>');
        $errors = array();
        $dialog->writeGeneratorSummary($output, $errors);
        $output->writeln('You must run the plugin install command manually: <comment>php application/console plugins:install ' . strtolower($vendor) . '/' . strtolower($pluginName) . '-plugin-bundle</comment>');
    }