cvs: pear /SOAP Base.php
| From: | Shane Caraveo | Date: | Sat, 17 Aug 2002 02:37:34 +0000 |
| Subject: | cvs: pear /SOAP Base.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5775@lists.php.net to get a copy of this message | ||
shane Fri Aug 16 22:37:34 2002 EDT
Modified files:
/pear/SOAP Base.php
Log:
Add ability to translate complex types to php classes
Index: pear/SOAP/Base.php
diff -u pear/SOAP/Base.php:1.19 pear/SOAP/Base.php:1.20
--- pear/SOAP/Base.php:1.19 Sun Jul 7 20:36:47 2002
+++ pear/SOAP/Base.php Fri Aug 16 22:37:34 2002
@@ -17,7 +17,7 @@
// | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author |
// +----------------------------------------------------------------------+
//
-// $Id: Base.php,v 1.19 2002/07/08 00:36:47 shane Exp $
+// $Id: Base.php,v 1.20 2002/08/17 02:37:34 shane Exp $
//
/*
@@ -112,7 +112,7 @@
* Common base class of all Soap lclasses
*
* @access public
-* @version $Id: Base.php,v 1.19 2002/07/08 00:36:47 shane Exp $
+* @version $Id: Base.php,v 1.20 2002/08/17 02:37:34 shane Exp $
* @package SOAP::Client
* @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates
*/
@@ -237,6 +237,11 @@
* @var boolean defines if we use section 5 encoding, or false if this is literal
*/
var $section5 = TRUE;
+
+ // handle type to class mapping
+ var $_auto_translation = false;
+ var $_type_translation = array();
+
/**
* Constructor
@@ -653,7 +658,21 @@
return $soapval;
} else if (is_array($soapval->value)) {
if ($SOAP_OBJECT_STRUCT && $soapval->type != 'Array') {
- $return = new stdClass();
+ $classname = 'stdClass';
+ if (isset($this->_type_translation[$soapval->tqn->fqn()])) {
+ // this will force an error in php if the
+ // class does not exist
+ $classname = $this->_type_translation[$soapval->tqn->fqn()];
+ } else if (isset($this->_type_translation[$soapval->type])) {
+ // this will force an error in php if the
+ // class does not exist
+ $classname = $this->_type_translation[$soapval->type];
+ } else if ($this->_auto_translation) {
+ if (class_exists($soapval->type)) {
+ $classname = $soapval->type;
+ }
+ }
+ $return = new $classname;
} else {
$return = array();
}
@@ -886,6 +905,14 @@
}
}
+ function __set_type_translation($type, $class=NULL)
+ {
+ $tq = new QName($type);
+ if (!$class) {
+ $class = $tq->name;
+ }
+ $this->_type_translation[$type]=$class;
+ }
}
/**
@@ -893,7 +920,7 @@
* class used to handle QNAME values in XML
*
* @access public
-* @version $Id: Base.php,v 1.19 2002/07/08 00:36:47 shane Exp $
+* @version $Id: Base.php,v 1.20 2002/08/17 02:37:34 shane Exp $
* @package SOAP::Client
* @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates
*/
@@ -940,5 +967,6 @@
}
return $this->name;
}
+
}
?>