/** * Executes the business logic involved with this command. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $parse_command = $this->getApplication()->find('project:parse'); $transform_command = $this->getApplication()->find('project:transform'); $parse_input = new ArrayInput(array('command' => 'project:parse', '--target' => $input->getOption('target'), '--filename' => $input->getOption('filename'), '--directory' => $input->getOption('directory'), '--extensions' => $input->getOption('extensions'), '--ignore' => $input->getOption('ignore'), '--ignore-tags' => $input->getOption('ignore-tags'), '--hidden' => $input->getOption('hidden'), '--ignore-symlinks' => $input->getOption('ignore-symlinks'), '--markers' => $input->getOption('markers'), '--title' => $input->getOption('title'), '--force' => $input->getOption('force'), '--validate' => $input->getOption('validate'), '--visibility' => $input->getOption('visibility'), '--defaultpackagename' => $input->getOption('defaultpackagename'), '--sourcecode' => $input->getOption('sourcecode'), '--progressbar' => $input->getOption('progressbar')), $this->getDefinition()); $return_code = $parse_command->run($parse_input, $output); if ($return_code !== 0) { return $return_code; } $target = $input->getOption('target'); if (!is_dir($target)) { $target = dirname($target); } $transform_input = new ArrayInput(array('command' => 'project:transform', '--source' => $input->getOption('target'), '--target' => $target, '--template' => $input->getOption('template'), '--parseprivate' => $input->getOption('parseprivate'), '--progressbar' => $input->getOption('progressbar'))); $return_code = $transform_command->run($transform_input, $output); if ($return_code !== 0) { return $return_code; } return 0; }
/** * Adds the transformer.transformation.post event to advance the progressbar. * * @param \Symfony\Component\Console\Input\InputInterface $input * * @return \Symfony\Component\Console\Helper\HelperInterface|null */ protected function getProgressBar(InputInterface $input) { $progress = parent::getProgressBar($input); if (!$progress) { return null; } $this->getService('event_dispatcher')->addListener('transformer.transformation.post', function () use($progress) { $progress->advance(); }); return $progress; }
/** * Adds the parser.file.pre event to the advance the progressbar. * * @param InputInterface $input * * @return \Symfony\Component\Console\Helper\HelperInterface|null */ protected function getProgressBar(InputInterface $input) { $progress = parent::getProgressBar($input); if (!$progress) { return null; } $this->getService('event_dispatcher')->addListener('parser.file.pre', function (PreFileEvent $event) use($progress) { $progress->advance(); }); return $progress; }