Пример #1
0
 /**
  * Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment.
  *
  * @param string $type
  * @return string tns:xsd-type
  */
 public function addComplexType($type)
 {
     if (in_array($type, $this->_inProcess)) {
         throw new WSDL\Exception("Infinite recursion, cannot nest '{$type}' into itself.");
     }
     $this->_inProcess[$type] = $type;
     $nestingLevel = $this->_getNestedCount($type);
     if ($nestingLevel > 1) {
         throw new WSDL\Exception('ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ' . 'one level. Use array object properties to return deep nested data.');
     }
     $singularType = $this->_getSingularPhpType($type);
     if (!class_exists($singularType)) {
         throw new WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type));
     }
     if ($nestingLevel == 1) {
         // The following blocks define the Array of Object structure
         $xsdComplexTypeName = $this->_addArrayOfComplexType($singularType, $type);
     } else {
         $xsdComplexTypeName = $singularType;
     }
     // The array for the objects has been created, now build the object definition:
     if (!in_array($singularType, $this->getContext()->getTypes())) {
         parent::addComplexType($singularType);
     }
     unset($this->_inProcess[$type]);
     return 'tns:' . $xsdComplexTypeName;
 }
Пример #2
0
 /**
  * Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment.
  *
  * @param string $singularType   e.g. '\MyNamespace\MyClassname'
  * @param string $type           e.g. '\MyNamespace\MyClassname[]'
  * @return string tns:xsd-type   e.g. 'tns:ArrayOfMyNamespace.MyClassname'
  */
 protected function _addArrayOfComplexType($singularType, $type)
 {
     if (($soapType = $this->scanRegisteredTypes($type)) !== null) {
         return $soapType;
     }
     $xsdComplexTypeName = 'ArrayOf' . Wsdl::translateType($singularType);
     $xsdComplexType = 'tns:' . $xsdComplexTypeName;
     // Register type here to avoid recursion
     $this->getContext()->addType($type, $xsdComplexType);
     // Process singular type using DefaultComplexType strategy
     parent::addComplexType($singularType);
     // Add array type structure to WSDL document
     $dom = $this->getContext()->toDomDocument();
     $complexType = $dom->createElement('xsd:complexType');
     $complexType->setAttribute('name', $xsdComplexTypeName);
     $complexContent = $dom->createElement('xsd:complexContent');
     $complexType->appendChild($complexContent);
     $xsdRestriction = $dom->createElement('xsd:restriction');
     $xsdRestriction->setAttribute('base', 'soap-enc:Array');
     $complexContent->appendChild($xsdRestriction);
     $xsdAttribute = $dom->createElement('xsd:attribute');
     $xsdAttribute->setAttribute('ref', 'soap-enc:arrayType');
     $xsdAttribute->setAttribute('wsdl:arrayType', 'tns:' . Wsdl::translateType($singularType) . '[]');
     $xsdRestriction->appendChild($xsdAttribute);
     $this->getContext()->getSchema()->appendChild($complexType);
     return $xsdComplexType;
 }
Пример #3
0
 /**
  * Add an unbounded ArrayOfType based on the xsd:sequence syntax if type[] is detected in return value doc comment.
  *
  * @param string $type
  * @return string tns:xsd-type
  */
 public function addComplexType($type)
 {
     $nestedCounter = $this->_getNestedCount($type);
     if ($nestedCounter > 0) {
         $singularType = $this->_getSingularType($type);
         for ($i = 1; $i <= $nestedCounter; $i++) {
             $complexType = $this->_getTypeBasedOnNestingLevel($singularType, $i);
             $complexTypePhp = $singularType . str_repeat('[]', $i);
             $childType = $this->_getTypeBasedOnNestingLevel($singularType, $i - 1);
             $this->_addSequenceType($complexType, $childType, $complexTypePhp);
         }
         return $complexType;
     } else {
         if (($soapType = $this->scanRegisteredTypes($type)) !== null) {
             // Existing complex type
             return $soapType;
         } else {
             // New singular complex type
             return parent::addComplexType($type);
         }
     }
 }