/** * 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) { // invoke parent to load custom config parent::execute($input, $output); /** @var \phpDocumentor\Console\Helper\ProgressHelper $progress */ $progress = $this->getProgressBar($input); if (!$progress) { $this->connectOutputToLogging($output); } $output->write('Initializing transformer ..'); // initialize transformer $transformer = new \phpDocumentor\Transformer\Transformer(); $transformer->setTemplatesPath(__DIR__ . '/../../../../data/templates'); $target = $this->getOption($input, 'target', 'transformer/target'); if (!$this->isAbsolute($target)) { $target = getcwd() . DIRECTORY_SEPARATOR . $target; } $transformer->setTarget($target); $source = realpath($this->getOption($input, 'source', 'parser/target')); if (file_exists($source) and is_dir($source)) { $source .= DIRECTORY_SEPARATOR . 'structure.xml'; } $transformer->setSource($source); $templates = $this->getTemplates($input); $transformer->setTemplates($templates); $transformer->setParseprivate($input->getOption('parseprivate')); // add links to external docs $external_class_documentation = (array) $this->getConfigValueFromPath('transformer/external-class-documentation'); if (!isset($external_class_documentation[0])) { $external_class_documentation = array($external_class_documentation); } foreach ($external_class_documentation as $doc) { if (empty($doc)) { continue; } $transformer->setExternalClassDoc((string) $doc['prefix'], (string) $doc['uri']); } $output->writeln(' OK'); $output->write('Processing behaviours ..'); $this->getService('event_dispatcher')->addListener('transformer.transform.pre', function () use($output) { $output->writeln(' OK'); $output->writeln('Executing transformations'); }); if ($progress) { $progress->start($output, count($transformer->getTransformations())); } $transformer->execute(); if ($progress) { $progress->finish(); } return 0; }
/** * 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; }
/** * Executes the business logic involved with this command. * * @param InputInterface $input * @param OutputInterface $output * * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { // invoke parent to load custom config parent::execute($input, $output); /** @var \phpDocumentor\Console\Helper\ProgressHelper $progress */ $progress = $this->getProgressBar($input); if (!$progress) { $this->connectOutputToLogging($output); } $output->write('Initializing parser and collecting files .. '); $target = $this->getTarget($this->getOption($input, 'target', 'parser/target')); $parser = new \phpDocumentor\Parser\Parser(); $parser->setTitle((string) $this->getOption($input, 'title', 'title')); $parser->setExistingXml($target); $parser->setForced($input->getOption('force')); $parser->setMarkers($this->getOption($input, 'markers', 'parser/markers/item', null, true)); $parser->setIgnoredTags($input->getOption('ignore-tags')); $parser->setValidate($input->getOption('validate')); $parser->setVisibility((string) $this->getOption($input, 'visibility', 'parser/visibility')); $parser->setDefaultPackageName($this->getOption($input, 'defaultpackagename', 'parser/default-package-name')); $files = $this->getFileCollection($input); $parser->setPath($files->getProjectRoot()); if ($progress) { $progress->start($output, $files->count()); } try { // save the generate file to the path given as the 'target' option $output->writeln('OK'); $output->writeln('Parsing files'); $result = $parser->parseFiles($files, $input->getOption('sourcecode')); } catch (\Exception $e) { if ($e->getCode() === \phpDocumentor\Parser\Exception::NO_FILES_FOUND) { throw new \Exception('No parsable files were found, did you specify any using ' . 'the -f or -d parameter?'); } throw new \Exception($e->getMessage()); } if ($progress) { $progress->finish(); } $output->write('Storing structure.xml in "' . $target . '" .. '); file_put_contents($target, $result); $output->writeln('OK'); return 0; }
/** * Executes the business logic involved with this command. * * @param InputInterface $input * @param OutputInterface $output * * @return integer */ protected function execute(InputInterface $input, OutputInterface $output) { // invoke parent to load custom config parent::execute($input, $output); $target = $this->getOption($input, 'target', 'parser/target'); if (!$this->isAbsolute($target)) { $target = getcwd() . DIRECTORY_SEPARATOR . $target; } if (!file_exists($target)) { mkdir($target, 0777, true); } if (!is_dir($target)) { throw new \Exception($this->__('PPCPP:EXC-BADTARGET')); } $this->getCache()->getOptions()->setCacheDir($target); $builder = $this->getBuilder(); $builder->createProjectDescriptor(); $projectDescriptor = $builder->getProjectDescriptor(); $visibility = ProjectDescriptor\Settings::VISIBILITY_DEFAULT; if ($input->getOption('parseprivate')) { $visibility = $visibility | ProjectDescriptor\Settings::VISIBILITY_INTERNAL; } $projectDescriptor->getSettings()->setVisibility($visibility); $output->write($this->__('PPCPP:LOG-COLLECTING')); $files = $this->getFileCollection($input); $output->writeln($this->__('PPCPP:LOG-OK')); /** @var ProgressHelper $progress */ $progress = $this->getProgressBar($input); if (!$progress) { $this->connectOutputToLogging($output); } $output->write($this->__('PPCPP:LOG-INITIALIZING')); $this->populateParser($input, $files); if ($progress) { $progress->start($output, $files->count()); } try { $output->writeln($this->__('PPCPP:LOG-OK')); $output->writeln($this->__('PPCPP:LOG-PARSING')); $mapper = new ProjectDescriptorMapper($this->getCache()); $mapper->garbageCollect($files); $mapper->populate($projectDescriptor); $this->getParser()->parse($builder, $files); } catch (FilesNotFoundException $e) { throw new \Exception($this->__('PPCPP:EXC-NOFILES')); } catch (\Exception $e) { throw new \Exception($e->getMessage(), 0, $e); } if ($progress) { $progress->finish(); } $output->write($this->__('PPCPP:LOG-STORECACHE', (array) $this->getCache()->getOptions()->getCacheDir())); $mapper->save($projectDescriptor); $output->writeln($this->__('PPCPP:LOG-OK')); return 0; }
/** * 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) { // invoke parent to load custom config parent::execute($input, $output); /** @var \phpDocumentor\Console\Helper\ProgressHelper $progress */ $progress = $this->getProgressBar($input); if (!$progress) { $this->connectOutputToLogging($output); } // initialize transformer $transformer = $this->getTransformer(); $target = $this->getOption($input, 'target', 'transformer/target'); if (!$this->isAbsolute($target)) { $target = getcwd() . DIRECTORY_SEPARATOR . $target; } $transformer->setTarget($target); $source = realpath($this->getOption($input, 'source', 'parser/target')); if (!file_exists($source) || !is_dir($source)) { throw new \Exception('Invalid source location provided, a path to an existing folder was expected'); } $this->getCache()->getOptions()->setCacheDir($source); $projectDescriptor = $this->getBuilder()->getProjectDescriptor(); $mapper = new ProjectDescriptorMapper($this->getCache()); $output->writeTimedLog('Load cache', array($mapper, 'populate'), array($projectDescriptor)); foreach ($this->getTemplates($input) as $template) { $output->writeTimedLog('Preparing template "' . $template . '"', array($transformer->getTemplates(), 'load'), array($template, $transformer)); } $output->writeTimedLog('Preparing ' . count($transformer->getTemplates()->getTransformations()) . ' transformations', array($this, 'loadTransformations'), array($transformer)); if ($progress) { $progress->start($output, count($transformer->getTemplates()->getTransformations())); } /** @var CompilerPassInterface $pass */ foreach ($this->compiler as $pass) { $output->writeTimedLog($pass->getDescription(), array($pass, 'execute'), array($projectDescriptor)); } if ($progress) { $progress->finish(); } return 0; }