示例#1
0
 /**
  * @group ZF-5944
  */
 public function testOnlyPublicPropertiesAreDiscoveredByStrategy()
 {
     $this->strategy->addComplexType('ZendTest\\Soap\\TestAsset\\PublicPrivateProtected');
     $nodes = $this->xpath->query('//xsd:element[@name="' . PublicPrivateProtected::PROTECTED_VAR_NAME . '"]');
     $this->assertEquals(0, $nodes->length, 'Document should not contain protected fields');
     $nodes = $this->xpath->query('//xsd:element[@name="' . PublicPrivateProtected::PRIVATE_VAR_NAME . '"]');
     $this->assertEquals(0, $nodes->length, 'Document should not contain private fields');
     $this->testDocumentNodes();
 }
 /**
  * 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' . $this->getContext()->translateType($singularType);
     $xsdComplexType = Wsdl::TYPES_NS . ':' . $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->createElementNS(Wsdl::XSD_NS_URI, 'complexType');
     $this->getContext()->getSchema()->appendChild($complexType);
     $complexType->setAttribute('name', $xsdComplexTypeName);
     $complexContent = $dom->createElementNS(Wsdl::XSD_NS_URI, 'complexContent');
     $complexType->appendChild($complexContent);
     $xsdRestriction = $dom->createElementNS(Wsdl::XSD_NS_URI, 'restriction');
     $complexContent->appendChild($xsdRestriction);
     $xsdRestriction->setAttribute('base', Wsdl::SOAP_ENC_NS . ':Array');
     $xsdAttribute = $dom->createElementNS(Wsdl::XSD_NS_URI, 'attribute');
     $xsdRestriction->appendChild($xsdAttribute);
     $xsdAttribute->setAttribute('ref', Wsdl::SOAP_ENC_NS . ':arrayType');
     $xsdAttribute->setAttributeNS(Wsdl::WSDL_NS_URI, 'arrayType', Wsdl::TYPES_NS . ':' . $this->getContext()->translateType($singularType) . '[]');
     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;
     } elseif (($soapType = $this->scanRegisteredTypes($type)) !== null) {
         // Existing complex type
         return $soapType;
     } else {
         // New singular complex type
         return parent::addComplexType($type);
     }
 }