|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00026 require_once "Zend/Soap/Wsdl/Strategy/Abstract.php"; 00027 00037 class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract 00038 { 00045 public function addComplexType($type) 00046 { 00047 if(!class_exists($type)) { 00048 require_once "Zend/Soap/Wsdl/Exception.php"; 00049 throw new Zend_Soap_Wsdl_Exception(sprintf( 00050 "Cannot add a complex type %s that is not an object or where ". 00051 "class could not be found in 'DefaultComplexType' strategy.", $type 00052 )); 00053 } 00054 00055 $dom = $this->getContext()->toDomDocument(); 00056 $class = new ReflectionClass($type); 00057 00058 $complexType = $dom->createElement('xsd:complexType'); 00059 $complexType->setAttribute('name', $type); 00060 00061 $all = $dom->createElement('xsd:all'); 00062 00063 foreach ($class->getProperties() as $property) { 00064 if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) { 00065 00070 $element = $dom->createElement('xsd:element'); 00071 $element->setAttribute('name', $property->getName()); 00072 $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); 00073 $all->appendChild($element); 00074 } 00075 } 00076 00077 $complexType->appendChild($all); 00078 $this->getContext()->getSchema()->appendChild($complexType); 00079 $this->getContext()->addType($type); 00080 00081 return "tns:$type"; 00082 } 00083 }