7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
18
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
* @license http://framework.zend.com/license/new-bsd New BSD License
23
class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract
26
* Add a complex type by recursivly using all the class properties fetched via Reflection.
28
* @param string $type Name of the class to be specified
29
* @return string XSD Type for the given PHP type
31
public function addComplexType($type)
33
if(!class_exists($type)) {
34
require_once "Zend/Soap/Wsdl/Exception.php";
35
throw new Zend_Soap_Wsdl_Exception(sprintf(
36
"Cannot add a complex type %s that is not an object or where ".
37
"class could not be found in 'DefaultComplexType' strategy.", $type
41
$dom = $this->getContext()->toDomDocument();
42
$class = new ReflectionClass($type);
44
$complexType = $dom->createElement('xsd:complexType');
45
$complexType->setAttribute('name', $type);
47
$all = $dom->createElement('xsd:all');
49
foreach ($class->getProperties() as $property) {
50
if (preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
53
* @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
54
* node for describing other classes used as attribute types for current class
56
$element = $dom->createElement('xsd:element');
57
$element->setAttribute('name', $property->getName());
58
$element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
59
$all->appendChild($element);
63
$complexType->appendChild($all);
64
$this->getContext()->getSchema()->appendChild($complexType);
65
$this->getContext()->addType($type);