/** * 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; }
/** * Runs phpDocumentor 2 */ public function run() { $this->initializePhpDocumentor(); $xml = $this->parseFiles(); $this->project->log("Transforming...", Project::MSG_VERBOSE); $transformer = new phpDocumentor\Transformer\Transformer(); $transformer->setTemplatesPath($this->phpDocumentorPath . '/../data/templates'); $transformer->setTemplates($this->template); $transformer->setSource($xml); $transformer->setTarget($this->destDir->getAbsolutePath()); $transformer->execute(); }