Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DefaultComplexType.php
Go to the documentation of this file.
1 <?php
26 #require_once "Zend/Soap/Wsdl/Strategy/Abstract.php";
27 
38 {
45  public function addComplexType($type)
46  {
47  if(!class_exists($type)) {
48  #require_once "Zend/Soap/Wsdl/Exception.php";
49  throw new Zend_Soap_Wsdl_Exception(sprintf(
50  "Cannot add a complex type %s that is not an object or where ".
51  "class could not be found in 'DefaultComplexType' strategy.", $type
52  ));
53  }
54 
55  $dom = $this->getContext()->toDomDocument();
56  $class = new ReflectionClass($type);
57 
58  $defaultProperties = $class->getDefaultProperties();
59 
60  $complexType = $dom->createElement('xsd:complexType');
61  $complexType->setAttribute('name', $type);
62 
63  $all = $dom->createElement('xsd:all');
64 
65  foreach ($class->getProperties() as $property) {
66  if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
67 
72  $element = $dom->createElement('xsd:element');
73  $element->setAttribute('name', $propertyName = $property->getName());
74  $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
75 
76  // If the default value is null, then this property is nillable.
77  if ($defaultProperties[$propertyName] === null) {
78  $element->setAttribute('nillable', 'true');
79  }
80 
81  $all->appendChild($element);
82  }
83  }
84 
85  $complexType->appendChild($all);
86  $this->getContext()->getSchema()->appendChild($complexType);
87  $this->getContext()->addType($type);
88 
89  return "tns:$type";
90  }
91 }
$type
Definition: item.phtml:13
$_option $_optionId $class
Definition: date.phtml:13
$element
Definition: element.phtml:12