Ejemplo n.º 1
0
 /**
  * Loads all type classes
  */
 protected function loadTypes()
 {
     $this->log('Loading types');
     $types = $this->wsdl->getTypes();
     foreach ($types as $typeNode) {
         $type = null;
         if ($typeNode->isComplex()) {
             $type = new ComplexType($this->config, $typeNode->getName());
             $this->log('Loading type ' . $type->getPhpIdentifier());
             $type->setAbstract($typeNode->isAbstract());
             foreach ($typeNode->getParts() as $name => $typeName) {
                 // There are 2 ways a wsdl can indicate that a field accepts the null value -
                 // by setting the "nillable" attribute to "true" or by setting the "minOccurs" attribute to "0".
                 // See http://www.ibm.com/developerworks/webservices/library/ws-tip-null/index.html
                 $nullable = $typeNode->isElementNillable($name) || $typeNode->getElementMinOccurs($name) === 0;
                 $type->addMember($typeName, $name, $nullable);
             }
         } elseif ($enumValues = $typeNode->getEnumerations()) {
             $type = new Enum($this->config, $typeNode->getName(), $typeNode->getRestriction());
             array_walk($enumValues, function ($value) use($type) {
                 $type->addValue($value);
             });
         } elseif ($pattern = $typeNode->getPattern()) {
             $type = new Pattern($this->config, $typeNode->getName(), $typeNode->getRestriction());
             $type->setValue($pattern);
         }
         if ($type != null) {
             $already_registered = false;
             if ($this->config->get('sharedTypes')) {
                 foreach ($this->types as $registered_types) {
                     if ($registered_types->getIdentifier() == $type->getIdentifier()) {
                         $already_registered = true;
                         break;
                     }
                 }
             }
             if (!$already_registered) {
                 $this->types[$typeNode->getName()] = $type;
             }
         }
     }
     // Loop through all types again to setup class inheritance.
     // We can only do this once all types have been loaded. Otherwise we risk referencing types which have not been
     // loaded yet.
     foreach ($types as $type) {
         if (($baseType = $type->getBase()) && isset($this->types[$baseType]) && $this->types[$baseType] instanceof ComplexType) {
             $this->types[$type->getName()]->setBaseType($this->types[$baseType]);
         }
     }
     $this->log('Done loading types');
 }
Ejemplo n.º 2
0
 /**
  * Loads all type classes
  */
 private function loadTypes()
 {
     $this->log('Loading types');
     $types = $this->wsdl->getTypes();
     foreach ($types as $typeNode) {
         if ($typeNode->isArray()) {
             // skip arrays
             continue;
         }
         $type = null;
         if ($typeNode->isComplex()) {
             $type = new ComplexType($this->config, $typeNode->getName());
             $this->log('Loading type ' . $type->getPhpIdentifier());
             foreach ($typeNode->getParts() as $name => $typeName) {
                 $type->addMember($typeName, $name, $typeNode->isElementNillable($name));
             }
         } elseif ($enumValues = $typeNode->getEnumerations()) {
             $type = new Enum($this->config, $typeNode->getName(), $typeNode->getRestriction());
             array_walk($enumValues, function ($value) use($type) {
                 $type->addValue($value);
             });
         } elseif ($pattern = $typeNode->getPattern()) {
             $type = new Pattern($this->config, $typeNode->getName(), $typeNode->getRestriction());
             $type->setValue($pattern);
         }
         if ($type != null) {
             $already_registered = false;
             if ($this->config->getSharedTypes()) {
                 foreach ($this->types as $registered_types) {
                     if ($registered_types->getIdentifier() == $type->getIdentifier()) {
                         $already_registered = true;
                         break;
                     }
                 }
             }
             if (!$already_registered) {
                 $this->types[$typeNode->getName()] = $type;
             }
         }
     }
     // Loop through all types again to setup class inheritance.
     // We can only do this once all types have been loaded. Otherwise we risk referencing types which have not been
     // loaded yet.
     foreach ($types as $type) {
         if (($baseType = $type->getBase()) && isset($this->types[$baseType])) {
             $this->types[$type->getName()]->setBaseType($this->types[$baseType]);
         }
     }
     $this->log('Done loading types');
 }