public function testExec() { $compiler = new ThriftCompiler(); // Bad exec path $this->setExpectedException('Overblog\\ThriftBundle\\Exception\\ConfigurationException', 'Unable to find Thrift executable'); $compiler->setExecPath(__DIR__); }
/** * Execute compilation * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $compiler = new ThriftCompiler(); if ($path = $input->getOption('path')) { $compiler->setExecPath($path); } $service = $input->getArgument('service'); $configs = $this->getContainer()->getParameter('thrift.config.services'); // Get config if (isset($configs[$service])) { $config = $configs[$service]; } else { $output->writeln(sprintf('<error>Unknow service %s</error>', $service)); return 1; } // Get definition path $definitionPath = $this->getContainer()->get('thrift.compile_warmer')->getDefinitionPath($config['definition'], $config['definitionPath']); // Get out path if ($bundleName = $input->getOption('bundleNameOut')) { $bundle = $this->getContainer()->get('kernel')->getBundle($bundleName); $bundlePath = $bundle->getPath(); } else { $bundlePath = getcwd(); } //Set Path $compiler->setModelPath(sprintf('%s/%s', $bundlePath, ThriftCompileCacheWarmer::CACHE_SUFFIX)); //Set include dirs if ($includeDirs = $input->getOption('includeDir')) { $compiler->setIncludeDirs($includeDirs); } //Add namespace prefix if needed if ($input->getOption('namespace')) { $compiler->setNamespacePrefix($input->getOption('namespace')); } $return = $compiler->compile($definitionPath, $input->getOption('server')); //Error if (1 === $return) { $output->writeln(sprintf('<error>%s</error>', implode("\n", $compiler->getLastOutput()))); } else { $output->writeln(sprintf('<info>%s</info>', implode("\n", $compiler->getLastOutput()))); } }