Example #1
0
 public function __construct($phpType, $arrayOf, $xmlTypeOf)
 {
     if ($arrayOf instanceof TypeInterface) {
         $arrayOf = $arrayOf->getPhpType();
     }
     parent::__construct($phpType, 'ArrayOf' . ucfirst($xmlTypeOf ?: $arrayOf));
     $this->add('item', $arrayOf);
 }
 public function __construct($phpType, $arrayOf, $xmlTypeOf, $nillable = null, $minOccurs = null, $maxOccurs = null, $pattern = null)
 {
     if ($arrayOf instanceof TypeInterface) {
         $arrayOf = $arrayOf->getPhpType();
     }
     parent::__construct($phpType, 'ArrayOf' . ucfirst($xmlTypeOf ?: $arrayOf));
     $this->add('item', $arrayOf, $nillable, $minOccurs, $maxOccurs, $pattern);
 }
Example #3
0
 /**
  * Loads all type classes
  *
  * @access private
  */
 private function loadTypes()
 {
     $this->log($this->display('Loading types'));
     $types = $this->client->__getTypes();
     foreach ($types as $typeStr) {
         $wsdlNewline = strpos($typeStr, "\r\n") ? "\r\n" : "\n";
         $parts = explode($wsdlNewline, $typeStr);
         $tArr = explode(" ", $parts[0]);
         $restriction = $tArr[0];
         $className = $tArr[1];
         if (substr($className, -2, 2) == '[]' || substr($className, 0, 7) == 'ArrayOf') {
             // skip arrays
             continue;
         }
         $type = null;
         $numParts = count($parts);
         // ComplexType
         if ($numParts > 1) {
             $type = new ComplexType($className);
             $this->log($this->display('Loading type ') . $type->getPhpIdentifier());
             for ($i = 1; $i < $numParts - 1; $i++) {
                 $parts[$i] = trim($parts[$i]);
                 list($typename, $name) = explode(" ", substr($parts[$i], 0, strlen($parts[$i]) - 1));
                 $name = $this->cleanNamespace($name);
                 $type->addMember($typename, $name);
             }
         } else {
             $typenode = $this->findTypenode($className);
             if ($typenode) {
                 // If enum
                 $enumerationList = $typenode->getElementsByTagName('enumeration');
                 $patternList = $typenode->getElementsByTagName('pattern');
                 if ($enumerationList->length > 0) {
                     $type = new Enum($className, $restriction);
                     $this->log($this->display('Loading enum ') . $type->getPhpIdentifier());
                     foreach ($enumerationList as $enum) {
                         $type->addValue($enum->attributes->getNamedItem('value')->nodeValue);
                     }
                 } else {
                     if ($patternList->length > 0) {
                         $type = new Pattern($className, $restriction);
                         $this->log($this->display('Loading pattern ') . $type->getPhpIdentifier());
                         $type->setValue($patternList->item(0)->attributes->getNamedItem('value')->nodeValue);
                     } else {
                         continue;
                         // Don't load the type if we don't know what it is
                     }
                 }
             }
         }
         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[] = $type;
             }
         }
     }
     $this->log($this->display('Done loading types'));
 }
Example #4
0
 /**
  * Loads all type classes
  *
  * @access private
  */
 private function loadTypes()
 {
     $this->log($this->display('Loading types'));
     $types = $this->client->__getTypes();
     foreach ($types as $typeStr) {
         $wsdlNewline = strpos($typeStr, "\r\n") ? "\r\n" : "\n";
         $parts = explode($wsdlNewline, $typeStr);
         $tArr = explode(" ", $parts[0]);
         $restriction = $tArr[0];
         $className = $tArr[1];
         if (substr($className, -2, 2) == '[]' || substr($className, 0, 7) == 'ArrayOf') {
             // skip arrays
             continue;
         }
         $arrayVars = $this->findArrayElements($className);
         $type = null;
         $numParts = count($parts);
         // ComplexType
         if ($numParts > 1) {
             $type = new ComplexType($className);
             $this->log($this->display('Loading type ') . $type->getPhpIdentifier());
             for ($i = 1; $i < $numParts - 1; $i++) {
                 $parts[$i] = trim($parts[$i]);
                 list($typename, $name) = explode(" ", substr($parts[$i], 0, strlen($parts[$i]) - 1));
                 $name = $this->cleanNamespace($name);
                 if (array_key_exists($name, $arrayVars)) {
                     $typename .= '[]';
                 }
                 $nillable = false;
                 foreach ($this->schema as $schema) {
                     $tmp = $schema->xpath('//xs:complexType[@name = "' . $className . '"]/descendant::xs:element[@name = "' . $name . '"]/@nillable');
                     if (!empty($tmp) && (string) $tmp[0] == 'true') {
                         $nillable = true;
                         break;
                     }
                 }
                 $type->addMember($typename, $name, $nillable);
             }
         } else {
             // Enum or Pattern
             $typenode = $this->findTypenode($className);
             if ($typenode) {
                 // If enum
                 $enumerationList = $typenode->getElementsByTagName('enumeration');
                 $patternList = $typenode->getElementsByTagName('pattern');
                 if ($enumerationList->length > 0) {
                     $type = new Enum($className, $restriction);
                     $this->log($this->display('Loading enum ') . $type->getPhpIdentifier());
                     foreach ($enumerationList as $enum) {
                         $type->addValue($enum->attributes->getNamedItem('value')->nodeValue);
                     }
                 } elseif ($patternList->length > 0) {
                     // If pattern
                     $type = new Pattern($className, $restriction);
                     $this->log($this->display('Loading pattern ') . $type->getPhpIdentifier());
                     $type->setValue($patternList->item(0)->attributes->getNamedItem('value')->nodeValue);
                 } else {
                     continue;
                     // Don't load the type if we don't know what it is
                 }
             }
         }
         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[] = $type;
             }
         }
     }
     $this->log($this->display('Done loading types'));
 }