Beispiel #1
0
 /**
  * Convert service response into format acceptable by SoapServer.
  *
  * @param object|array|string|int|float|null $data
  * @return array
  * @throws \InvalidArgumentException
  */
 protected function _prepareResponseData($data)
 {
     $result = null;
     if ($data instanceof AbstractSimpleObject) {
         $result = $this->_dataObjectConverter->convertKeysToCamelCase($data->__toArray());
     } elseif (is_array($data)) {
         foreach ($data as $key => $value) {
             if ($value instanceof AbstractSimpleObject) {
                 $result[] = $this->_dataObjectConverter->convertKeysToCamelCase($value->__toArray());
             } else {
                 $result[$key] = $value;
             }
         }
     } elseif (is_scalar($data) || is_null($data)) {
         $result = $data;
     } else {
         throw new \InvalidArgumentException("Service returned result in invalid format.");
     }
     return array(self::RESULT_NODE_NAME => $result);
 }