summaryrefslogtreecommitdiff
path: root/ext/soap/php_encoding.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2004-02-16 16:35:59 +0000
committerDmitry Stogov <dmitry@php.net>2004-02-16 16:35:59 +0000
commit3e002aa66df80e01879ca8339fc50607c3578d8c (patch)
treef429d99a33bd9e3a44b275b4822de17a939cfd1c /ext/soap/php_encoding.c
parent1350643b8c1d9fded37b7db68d73566160ea802f (diff)
downloadphp-git-3e002aa66df80e01879ca8339fc50607c3578d8c.tar.gz
specal case of array encoding. If object has only one inner element and this element has max_occurs > 1, then array can be passed directly.
Diffstat (limited to 'ext/soap/php_encoding.c')
-rw-r--r--ext/soap/php_encoding.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index e33675125b..024a19c32e 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -1032,6 +1032,37 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, HashTa
return 1;
}
+static sdlTypePtr model_array_element(sdlContentModelPtr model)
+{
+ switch (model->kind) {
+ case XSD_CONTENT_ELEMENT: {
+ if (model->max_occurs == -1 || model->max_occurs > 1) {
+ return model->u.element;
+ } else {
+ return NULL;
+ }
+ }
+ case XSD_CONTENT_SEQUENCE:
+ case XSD_CONTENT_ALL:
+ case XSD_CONTENT_CHOICE: {
+ sdlContentModelPtr *tmp;
+
+ if (zend_hash_num_elements(model->u.content) != 1) {
+ return NULL;
+ }
+ zend_hash_internal_pointer_reset(model->u.content);
+ zend_hash_get_current_data(model->u.content, (void**)&tmp);
+ return model_array_element(*tmp);
+ }
+ case XSD_CONTENT_GROUP: {
+ return model_array_element(model->u.group->model);
+ }
+ default:
+ break;
+ }
+ return NULL;
+}
+
static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNodePtr parent)
{
xmlNodePtr xmlParam;
@@ -1098,7 +1129,22 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo
FIND_ZVAL_NULL(data, xmlParam, style);
if (prop != NULL) {
- if (sdlType->model) {
+ sdlTypePtr array_el;
+
+ if (Z_TYPE_P(data) == IS_ARRAY &&
+ !is_map(data) &&
+ sdlType->attributes == NULL &&
+ sdlType->model != NULL &&
+ (array_el = model_array_element(sdlType->model)) != NULL) {
+ zval **val;
+
+ zend_hash_internal_pointer_reset(prop);
+ while (zend_hash_get_current_data(prop,(void**)&val) == SUCCESS) {
+ xmlNodePtr property = master_to_xml(array_el->encode, *val, style, xmlParam);
+ xmlNodeSetName(property, array_el->name);
+ zend_hash_move_forward(prop);
+ }
+ } else if (sdlType->model) {
model_to_xml_object(xmlParam, sdlType->model, prop, style, 1);
}
if (sdlType->attributes) {