You are here

function wsdl::serializeComplexTypeAttributes in Salesforce Suite 5

Same name in this branch
  1. 5 includes/nusoap.php \wsdl::serializeComplexTypeAttributes()
  2. 5 includes/nusoap.orig.php \wsdl::serializeComplexTypeAttributes()
Same name and namespace in other branches
  1. 5.2 includes/nusoap.php \wsdl::serializeComplexTypeAttributes()
  2. 5.2 includes/nusoap.orig.php \wsdl::serializeComplexTypeAttributes()

* serializes the attributes for a complexType * *

Parameters

array $typeDef our internal representation of an XML schema type (or element): * @param mixed $value a native PHP value (parameter value) * @param string $ns the namespace of the type * @param string $uqType the local part of the type * @return string value serialized as an XML string * @access private

2 calls to wsdl::serializeComplexTypeAttributes()
wsdl::serializeType in includes/nusoap.php
* serializes a PHP value according a given type definition * *
wsdl::serializeType in includes/nusoap.orig.php
* serializes a PHP value according a given type definition * *

File

includes/nusoap.orig.php, line 5463

Class

wsdl
parses a WSDL file, allows access to it's data, other utility methods

Code

function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
  $xml = '';
  if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
    $this
      ->debug("serialize attributes for XML Schema type {$ns}:{$uqType}");
    if (is_array($value)) {
      $xvalue = $value;
    }
    elseif (is_object($value)) {
      $xvalue = get_object_vars($value);
    }
    else {
      $this
        ->debug("value is neither an array nor an object for XML Schema type {$ns}:{$uqType}");
      $xvalue = array();
    }
    foreach ($typeDef['attrs'] as $aName => $attrs) {
      if (isset($xvalue['!' . $aName])) {
        $xname = '!' . $aName;
        $this
          ->debug("value provided for attribute {$aName} with key {$xname}");
      }
      elseif (isset($xvalue[$aName])) {
        $xname = $aName;
        $this
          ->debug("value provided for attribute {$aName} with key {$xname}");
      }
      elseif (isset($attrs['default'])) {
        $xname = '!' . $aName;
        $xvalue[$xname] = $attrs['default'];
        $this
          ->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
      }
      else {
        $xname = '';
        $this
          ->debug("no value provided for attribute {$aName}");
      }
      if ($xname) {
        $xml .= " {$aName}=\"" . $this
          ->expandEntities($xvalue[$xname]) . "\"";
      }
    }
  }
  else {
    $this
      ->debug("no attributes to serialize for XML Schema type {$ns}:{$uqType}");
  }
  if (isset($typeDef['extensionBase'])) {
    $ns = $this
      ->getPrefix($typeDef['extensionBase']);
    $uqType = $this
      ->getLocalPart($typeDef['extensionBase']);
    if ($this
      ->getNamespaceFromPrefix($ns)) {
      $ns = $this
        ->getNamespaceFromPrefix($ns);
    }
    if ($typeDef = $this
      ->getTypeDef($uqType, $ns)) {
      $this
        ->debug("serialize attributes for extension base {$ns}:{$uqType}");
      $xml .= $this
        ->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
    }
    else {
      $this
        ->debug("extension base {$ns}:{$uqType} is not a supported type");
    }
  }
  return $xml;
}