/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $destination = rtrim($input->getArgument('destination'), '/\\'); if (!$this->filesystem->dirextoryExists($destination)) { throw new RunTimeException(sprintf('The destination %s does not exist.', $destination)); } $wsdl = $input->getOption('wsdl'); if (!$wsdl) { throw new RuntimeException('You MUST specify a WSDL endpoint.'); } $namespace = $input->getOption('namespace'); $soapClient = new SoapClient($wsdl, []); $types = $soapClient->getSoapTypes(); $functions = $soapClient->getSoapFunctions(); $generator = new TypeGenerator($namespace); foreach ($types as $type => $properties) { // Check if file exists: $file = sprintf('%s/%s.php', $destination, ucfirst($type)); $data = $generator->generate($type, $properties, $functions); // Existing files ... if ($this->filesystem->fileExists($file)) { $output->write(sprintf('Client class %s exists. Trying to patch ...', $type)); $this->handleExistingFile($input, $output, $file, $type, $data); continue; } // New files... $this->filesystem->putFileContents($file, $data); $output->writeln(sprintf('Generated class %s to %s', $type, $file)); } $output->writeln('Done'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $wsdl = $input->getOption('wsdl'); if (!$wsdl) { throw new RuntimeException('You MUST specify a WSDL endpoint.'); } $namespace = $input->getOption('namespace'); $soapClient = new SoapClient($wsdl, []); $types = $soapClient->getSoapTypes(); $generator = new ClassmapGenerator($namespace); $output->write($generator->generate($types)); }
/** * @test * @vcr vcr-enabled.yml * * Note: this method will throw Exceptions if VCR can't take over the configured SoapClient. */ function it_should_be_possible_to_hook_php_vcr_for_testing() { $result = $this->client->GetCityWeatherByZIP(['ZIP' => '10013']); $this->assertTrue($result->GetCityWeatherByZIPResult->Success); }
/** * @param string $namespace * @param SoapClient $client * * @return TypeMap */ public static function fromSoapClient($namespace, SoapClient $client) { return new self($namespace, $client->getSoapTypes()); }