/**
  * 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;
 }
 /**
  * Test that the Checkstyle writer can identify parse_markers in the
  * structure.xml file and then build a checkstyle.xml checkstyle report
  *
  * @covers phpDocumentor\Plugin\Core\Transformer\Writer\Checkstyle::transform
  *
  * @param string $structure The xml in structure.xml
  * @param string $expected  The expected XML in checkstyle.xml
  *
  * @dataProvider provideDataForCheckStyleTransformation
  *
  * @return void
  */
 public function testTransformCanIdentifyParseMarkersAndCreateCheckstyleReport($structure, $expected)
 {
     $tr = new \phpDocumentor\Transformer\Transformer();
     $tr->setTarget('/tmp');
     $t = new \phpDocumentor\Transformer\Transformation($tr, '', 'Checkstyle', '', '/checkstyle.xml');
     $expectedDom = new \DOMDocument();
     $expectedDom->loadXML($expected);
     $document = new \DOMDocument();
     $document->loadXML($structure);
     $writer = new Checkstyle();
     $writer->transform($document, $t);
     $this->assertFileExists('/tmp/checkstyle.xml');
     $actual = file_get_contents('/tmp/checkstyle.xml');
     $this->assertEquals($expected, $actual);
 }
 public function testExecuteTransform()
 {
     touch('/tmp/phpdoc_a');
     @unlink('/tmp/phpdoc_b');
     $this->assertFileExists('/tmp/phpdoc_a');
     $this->assertFileNotExists('/tmp/phpdoc_b');
     $tr = new \phpDocumentor\Transformer\Transformer();
     $tr->setTarget('/tmp');
     try {
         $t = new \phpDocumentor\Transformer\Transformation($tr, 'copyz', 'FileIo', '/tmp/phpdoc_a', 'phpdoc_b');
         $this->fixture->transform(new \DOMDocument(), $t);
         $this->fail('When un unknown query type is used an exception is expected');
     } catch (\InvalidArgumentException $e) {
         // this is good
     }
     $this->markTestIncomplete('Absolute files are no longer supported using the FileIo writer, ' . 'the test code should be adapted');
     //       $t = new \phpDocumentor\Transformer\Transformation($tr, 'copy', 'FileIo', '/tmp/phpdoc_a', 'phpdoc_b');
     //        $this->fixture->transform(new DOMDocument(), $t);
     //        $this->assertFileExists('/tmp/phpdoc_a');
     //        $this->assertFileExists('/tmp/phpdoc_b');
     unlink('/tmp/phpdoc_a');
     unlink('/tmp/phpdoc_b');
 }
 /**
  * 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();
 }