/** * {@inheritdoc} * @throws \Phpro\SoapClient\Exception\InvalidArgumentException */ protected function execute(InputInterface $input, OutputInterface $output) { $configFile = $input->getOption('config'); if (!$configFile || !$this->filesystem->fileExists($configFile)) { throw InvalidArgumentException::invalidConfigFile(); } $config = (include $configFile); if (!$config instanceof ConfigInterface) { throw InvalidArgumentException::invalidConfigFile(); } $soapClient = new SoapClient($config->getWsdl(), $config->getSoapOptions()); $typeMap = TypeMap::fromSoapClient($config->getNamespace(), $soapClient); $file = new FileGenerator(); $generator = new ClassMapGenerator($config->getRuleSet()); $output->write($generator->generate($file, $typeMap)); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $this->input = $input; $this->output = $output; $configFile = $this->input->getOption('config'); if (!$configFile || !$this->filesystem->fileExists($configFile)) { throw InvalidArgumentException::invalidConfigFile(); } $config = (include $configFile); if (!$config instanceof ConfigInterface) { throw InvalidArgumentException::invalidConfigFile(); } $soapClient = new SoapClient($config->getWsdl(), $config->getSoapOptions()); $typeMap = TypeMap::fromSoapClient($config->getNamespace(), $soapClient); $generator = new TypeGenerator($config->getRuleSet()); foreach ($typeMap->getTypes() as $type) { $path = $type->getPathname($config->getDestination()); if ($this->handleType($generator, $type, $path)) { $this->output->writeln(sprintf('Generated class %s to %s', $type->getFullName(), $path)); } } $this->output->writeln('Done'); }
/** * @return string * @throws InvalidArgumentException */ public function getDestination() { if (!$this->destination) { throw InvalidArgumentException::destinationConfigurationIsMissing(); } return $this->destination; }