import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -1,7 +1,43 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
require_once "Interface.php";
/**
* Abstract class for Zend_Soap_Wsdl_Strategy.
*
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Soap_Wsdl_Strategy_Abstract implements Zend_Soap_Wsdl_Strategy_Interface
{
/**
* Context object
*
* @var Zend_Soap_Wsdl
*/
protected $_context;
/**

View File

@ -20,6 +20,8 @@
* @version $Id$
*/
require_once "Interface.php";
class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interface
{
/**

View File

@ -22,8 +22,10 @@
require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php";
class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy_Abstract
class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy_DefaultComplexType
{
protected $_inProcess = array();
/**
* Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment.
*
@ -32,6 +34,12 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy
*/
public function addComplexType($type)
{
if(in_array($type, $this->_inProcess)) {
require_once "Zend/Soap/Wsdl/Exception.php";
throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest '".$type."' into itsself.");
}
$this->_inProcess[$type] = $type;
$nestingLevel = $this->_getNestedCount($type);
if($nestingLevel > 1) {
@ -60,8 +68,11 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy
}
// The array for the objects has been created, now build the object definition:
$this->_addObjectComplexType($singularType);
if(!in_array($singularType, $this->getContext()->getTypes())) {
parent::addComplexType($singularType);
}
unset($this->_inProcess[$type]);
return "tns:".$xsdComplexTypeName;
}
@ -70,40 +81,30 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy
$dom = $this->getContext()->toDomDocument();
$xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType);
$complexType = $dom->createElement('xsd:complexType');
$complexType->setAttribute('name', $xsdComplexTypeName);
$complexContent = $dom->createElement("xsd:complexContent");
$complexType->appendChild($complexContent);
if(!in_array($xsdComplexTypeName, $this->getContext()->getTypes())) {
$complexType = $dom->createElement('xsd:complexType');
$complexType->setAttribute('name', $xsdComplexTypeName);
$xsdRestriction = $dom->createElement("xsd:restriction");
$xsdRestriction->setAttribute('base', 'soapenc:Array');
$complexContent->appendChild($xsdRestriction);
$complexContent = $dom->createElement("xsd:complexContent");
$complexType->appendChild($complexContent);
$xsdAttribute = $dom->createElement("xsd:attribute");
$xsdAttribute->setAttribute("ref", "soapenc:arrayType");
$xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType));
$xsdRestriction->appendChild($xsdAttribute);
$xsdRestriction = $dom->createElement("xsd:restriction");
$xsdRestriction->setAttribute('base', 'soap-enc:Array');
$complexContent->appendChild($xsdRestriction);
$this->getContext()->getSchema()->appendChild($complexType);
$this->getContext()->addType($type);
$xsdAttribute = $dom->createElement("xsd:attribute");
$xsdAttribute->setAttribute("ref", "soap-enc:arrayType");
$xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType));
$xsdRestriction->appendChild($xsdAttribute);
$this->getContext()->getSchema()->appendChild($complexType);
$this->getContext()->addType($xsdComplexTypeName);
}
return $xsdComplexTypeName;
}
protected function _addObjectComplexType($singularType)
{
$complexStrategy = $this->getContext()->getComplexTypeStrategy();
// Override strategy to stay DRY
$objectStrategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType();
$this->getContext()->setComplexTypeStrategy($objectStrategy);
$this->getContext()->addComplexType($singularType);
// Reset strategy
$this->getContext()->setComplexTypeStrategy($complexStrategy);
}
protected function _getXsdComplexTypeName($type)
{
return sprintf('ArrayOf%s', $type);

View File

@ -19,6 +19,8 @@
* @version $Id$
*/
require_once "Abstract.php";
class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_Abstract
{
/**
@ -41,7 +43,7 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strateg
$this->_addElementFromWsdlAndChildTypes($complexTypeName, $childTypeName);
}
// adding the PHP type which is resolved to a nested XSD type. therefore add only once.
$this->getContext()->addType($type);
$this->getContext()->addType($complexTypeName);
return "tns:$complexTypeName";
} else {

View File

@ -0,0 +1,174 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Interface
{
/**
* Typemap of Complex Type => Strategy pairs.
*
* @var array
*/
protected $_typeMap = array();
/**
* Default Strategy of this composite
*
* @var string|Zend_Soap_Wsdl_Strategy_Interface
*/
protected $_defaultStrategy;
/**
* Context WSDL file that this composite serves
*
* @var Zend_Soap_Wsdl|null
*/
protected $_context;
/**
* Construct Composite WSDL Strategy.
*
* @throws Zend_Soap_Wsdl_Exception
* @param array $typeMap
* @param string|Zend_Soap_Wsdl_Strategy_Interface $defaultStrategy
*/
public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_Wsdl_Strategy_DefaultComplexType")
{
foreach($typeMap AS $type => $strategy) {
$this->connectTypeToStrategy($type, $strategy);
}
$this->_defaultStrategy = $defaultStrategy;
}
/**
* Connect a complex type to a given strategy.
*
* @throws Zend_Soap_Wsdl_Exception
* @param string $type
* @param string|Zend_Soap_Wsdl_Strategy_Interface $strategy
* @return Zend_Soap_Wsdl_Strategy_Composite
*/
public function connectTypeToStrategy($type, $strategy)
{
if(!is_string($type)) {
/**
* @see Zend_Soap_Wsdl_Exception
*/
require_once "Zend/Soap/Wsdl/Exception.php";
throw new Zend_Soap_Wsdl_Exception("Invalid type given to Composite Type Map.");
}
$this->_typeMap[$type] = $strategy;
return $this;
}
/**
* Return default strategy of this composite
*
* @throws Zend_Soap_Wsdl_Exception
* @param string $type
* @return Zend_Soap_Wsdl_Strategy_Interface
*/
public function getDefaultStrategy()
{
$strategy = $this->_defaultStrategy;
if(is_string($strategy) && class_exists($strategy)) {
$strategy = new $strategy;
}
if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) {
/**
* @see Zend_Soap_Wsdl_Exception
*/
require_once "Zend/Soap/Wsdl/Exception.php";
throw new Zend_Soap_Wsdl_Exception(
"Default Strategy for Complex Types is not a valid strategy object."
);
}
$this->_defaultStrategy = $strategy;
return $strategy;
}
/**
* Return specific strategy or the default strategy of this type.
*
* @throws Zend_Soap_Wsdl_Exception
* @param string $type
* @return Zend_Soap_Wsdl_Strategy_Interface
*/
public function getStrategyOfType($type)
{
if(isset($this->_typeMap[$type])) {
$strategy = $this->_typeMap[$type];
if(is_string($strategy) && class_exists($strategy)) {
$strategy = new $strategy();
}
if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) {
/**
* @see Zend_Soap_Wsdl_Exception
*/
require_once "Zend/Soap/Wsdl/Exception.php";
throw new Zend_Soap_Wsdl_Exception(
"Strategy for Complex Type '".$type."' is not a valid strategy object."
);
}
$this->_typeMap[$type] = $strategy;
} else {
$strategy = $this->getDefaultStrategy();
}
return $strategy;
}
/**
* Method accepts the current WSDL context file.
*
* @param Zend_Soap_Wsdl $context
*/
public function setContext(Zend_Soap_Wsdl $context)
{
$this->_context = $context;
return $this;
}
/**
* Create a complex type based on a strategy
*
* @throws Zend_Soap_Wsdl_Exception
* @param string $type
* @return string XSD type
*/
public function addComplexType($type)
{
if(!($this->_context instanceof Zend_Soap_Wsdl) ) {
/**
* @see Zend_Soap_Wsdl_Exception
*/
require_once "Zend/Soap/Wsdl/Exception.php";
throw new Zend_Soap_Wsdl_Exception(
"Cannot add complex type '".$type."', no context is set for this composite strategy."
);
}
$strategy = $this->getStrategyOfType($type);
$strategy->setContext($this->_context);
return $strategy->addComplexType($type);
}
}

View File

@ -20,6 +20,8 @@
* @version $Id$
*/
require_once "Abstract.php";
class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract
{
/**
@ -47,7 +49,7 @@ class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy
$all = $dom->createElement('xsd:all');
foreach ($class->getProperties() as $property) {
if (preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
/**
* @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'

View File

@ -23,6 +23,11 @@
interface Zend_Soap_Wsdl_Strategy_Interface
{
/**
* Method accepts the current WSDL context file.
*
* @param <type> $context
*/
public function setContext(Zend_Soap_Wsdl $context);
/**