Phpro\SoapClient\Soap\SoapClient::getSoapTypes PHP Метод

getSoapTypes() публичный Метод

Retrieve SOAP types from the WSDL and parse them
public getSoapTypes ( ) : array
Результат array Array of types and their properties
    public function getSoapTypes()
    {
        if ($this->types) {
            return $this->types;
        }
        $soapTypes = $this->__getTypes();
        foreach ($soapTypes as $soapType) {
            $properties = array();
            $lines = explode("\n", $soapType);
            if (!preg_match('/struct (.*) {/', $lines[0], $matches)) {
                continue;
            }
            $typeName = $matches[1];
            foreach (array_slice($lines, 1) as $line) {
                if ($line == '}') {
                    continue;
                }
                preg_match('/\\s* (.*) (.*);/', $line, $matches);
                $properties[$matches[2]] = $matches[1];
            }
            $this->types[$typeName] = $properties;
        }
        return $this->types;
    }

Usage Example

Пример #1
0
 /**
  * {@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');
 }
All Usage Examples Of Phpro\SoapClient\Soap\SoapClient::getSoapTypes