/** * {@inheritDoc} * * @param InputInterface $input * @param OutputInterface $output * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { /** @var DialogHelper $dialog */ $dialog = $this->getHelperSet()->get('dialog'); $wsdl = Validators::validateWsdl($input->getOption('wsdl')); $dir = Validators::validateTargetDir($input->getOption('dir')); $namespace = Validators::validateNamespace($input->getOption('namespace')); $licensePath = Validators::validateLicensePath($input->getOption('license-path')); if ($input->isInteractive()) { $this->writeSection($output, array(sprintf('Path to the wsdl file: "%s"', $wsdl), sprintf('The directory where to create proxy classes: "%s"', $dir), sprintf('The namespace of proxy classes to create: "%s"', $namespace))); if (!$dialog->askConfirmation($output, $this->getQuestion('Do you confirm generation', 'yes', '?'), true)) { $output->writeln('<error>Command aborted</error>'); return 1; } } $generator = new SimpleTypeAbstractGenerator($wsdl, $dir . 'SimpleType', $namespace . '\\SimpleType', array(), $licensePath); $generator->execute(); $generator = new ComplexTypeAbstractGenerator($wsdl, $dir . 'ComplexType', $namespace . '\\ComplexType', array($namespace . '\\SimpleType'), $licensePath); $generator->execute(); $generator = new SimpleTypeGenerator($wsdl, $dir . 'SimpleType', $namespace . '\\SimpleType', array(), $licensePath); $generator->execute(); $generator = new ComplexTypeGenerator($wsdl, $dir . 'ComplexType', $namespace . '\\ComplexType', array($namespace . '\\SimpleType'), $licensePath); $generator->execute(); $generator = new SoapClientGenerator($wsdl, $dir, $namespace, array('RuntimeException', 'SoapFault', 'SoapClient as BaseSoapClient'), $licensePath); $generator->execute(); $generator = new SoapServiceGenerator($wsdl, $dir, $namespace, array('RuntimeException', 'SoapFault', 'SoapClient as BaseSoapClient', 'InvalidArgumentException'), $licensePath); $generator->execute(); unset($generator); }
/** * @param $path * @param $fileName * @param $code * @return int */ protected function saveCode($path, $fileName, $code) { if (!file_exists($path)) { mkdir($path, 0755, true); } $path = Validators::validateTargetDir($path); return file_put_contents($path . $fileName . '.php', $code); }
/** * @expectedException InvalidArgumentException */ public function testValidateTargetDirNotWriteable() { $targetDir = '/'; Validators::validateTargetDir($targetDir); }