Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex Class Reference
Inheritance diagram for Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex:
Zend_Soap_Wsdl_Strategy_DefaultComplexType Zend_Soap_Wsdl_Strategy_Abstract Zend_Soap_Wsdl_Strategy_Interface

Public Member Functions

 addComplexType ($type)
 
- Public Member Functions inherited from Zend_Soap_Wsdl_Strategy_DefaultComplexType
 addComplexType ($type)
 
- Public Member Functions inherited from Zend_Soap_Wsdl_Strategy_Abstract
 setContext (Zend_Soap_Wsdl $context)
 
 getContext ()
 

Protected Member Functions

 _addArrayOfComplexType ($singularType, $type)
 
 _getXsdComplexTypeName ($type)
 
 _getSingularPhpType ($type)
 
 _getNestedCount ($type)
 

Protected Attributes

 $_inProcess = array()
 
- Protected Attributes inherited from Zend_Soap_Wsdl_Strategy_Abstract
 $_context
 

Detailed Description

Definition at line 37 of file ArrayOfTypeComplex.php.

Member Function Documentation

◆ _addArrayOfComplexType()

_addArrayOfComplexType (   $singularType,
  $type 
)
protected

Definition at line 90 of file ArrayOfTypeComplex.php.

91  {
92  $dom = $this->getContext()->toDomDocument();
93 
94  $xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType);
95 
96  if(!in_array($xsdComplexTypeName, $this->getContext()->getTypes())) {
97  $complexType = $dom->createElement('xsd:complexType');
98  $complexType->setAttribute('name', $xsdComplexTypeName);
99 
100  $complexContent = $dom->createElement("xsd:complexContent");
101  $complexType->appendChild($complexContent);
102 
103  $xsdRestriction = $dom->createElement("xsd:restriction");
104  $xsdRestriction->setAttribute('base', 'soap-enc:Array');
105  $complexContent->appendChild($xsdRestriction);
106 
107  $xsdAttribute = $dom->createElement("xsd:attribute");
108  $xsdAttribute->setAttribute("ref", "soap-enc:arrayType");
109  $xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType));
110  $xsdRestriction->appendChild($xsdAttribute);
111 
112  $this->getContext()->getSchema()->appendChild($complexType);
113  $this->getContext()->addType($xsdComplexTypeName);
114  }
115 
116  return $xsdComplexTypeName;
117  }

◆ _getNestedCount()

_getNestedCount (   $type)
protected

Return the array nesting level based on the type name

Parameters
string$type
Returns
integer

Definition at line 141 of file ArrayOfTypeComplex.php.

142  {
143  return substr_count($type, "[]");
144  }
$type
Definition: item.phtml:13

◆ _getSingularPhpType()

_getSingularPhpType (   $type)
protected

From a nested definition with type[], get the singular PHP Type

Parameters
string$type
Returns
string

Definition at line 130 of file ArrayOfTypeComplex.php.

131  {
132  return str_replace("[]", "", $type);
133  }
$type
Definition: item.phtml:13

◆ _getXsdComplexTypeName()

_getXsdComplexTypeName (   $type)
protected

Definition at line 119 of file ArrayOfTypeComplex.php.

120  {
121  return sprintf('ArrayOf%s', $type);
122  }
$type
Definition: item.phtml:13

◆ addComplexType()

addComplexType (   $type)

Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment.

Parameters
string$type
Returns
string tns:xsd-type

Implements Zend_Soap_Wsdl_Strategy_Interface.

Definition at line 47 of file ArrayOfTypeComplex.php.

48  {
49  if (in_array($type, $this->_inProcess)) {
50  return "tns:" . $type;
51  }
52  $this->_inProcess[$type] = $type;
53 
54  $nestingLevel = $this->_getNestedCount($type);
55 
56  if($nestingLevel > 1) {
57  #require_once "Zend/Soap/Wsdl/Exception.php";
58  throw new Zend_Soap_Wsdl_Exception(
59  "ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ".
60  "one level. Use array object properties to return deep nested data.
61  ");
62  }
63 
64  $singularType = $this->_getSingularPhpType($type);
65 
66  if(!class_exists($singularType)) {
67  #require_once "Zend/Soap/Wsdl/Exception.php";
68  throw new Zend_Soap_Wsdl_Exception(sprintf(
69  "Cannot add a complex type %s that is not an object or where ".
70  "class could not be found in 'DefaultComplexType' strategy.", $type
71  ));
72  }
73 
74  if($nestingLevel == 1) {
75  // The following blocks define the Array of Object structure
76  $xsdComplexTypeName = $this->_addArrayOfComplexType($singularType, $type);
77  } else {
78  $xsdComplexTypeName = $singularType;
79  }
80 
81  // The array for the objects has been created, now build the object definition:
82  if(!in_array($singularType, $this->getContext()->getTypes())) {
83  parent::addComplexType($singularType);
84  }
85 
86  unset($this->_inProcess[$type]);
87  return "tns:".$xsdComplexTypeName;
88  }
$type
Definition: item.phtml:13

Field Documentation

◆ $_inProcess

$_inProcess = array()
protected

Definition at line 39 of file ArrayOfTypeComplex.php.


The documentation for this class was generated from the following file: