Fixed typo
This commit is contained in:
parent
4fa893042f
commit
ba0855a237
|
@ -16,71 +16,71 @@ use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType;
|
|||
|
||||
class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||
{
|
||||
private $definitionComplexTypes;
|
||||
|
||||
public function processMessage(Method $messageDefinition, $message, array $definitionComplexTypes = array())
|
||||
{
|
||||
$this->definitionComplexTypes = $definitionComplexTypes;
|
||||
|
||||
$result = array();
|
||||
$i = 0;
|
||||
|
||||
foreach($messageDefinition->getArguments() as $argument) {
|
||||
if (isset($message[$i])) {
|
||||
if (preg_match('/^([^\[]+)\[\]$/', $argument->getType()->getPhpType(), $match)) {
|
||||
$isArray = true;
|
||||
$type = $match[1];
|
||||
} else {
|
||||
$isArray = false;
|
||||
$type = $argument->getType()->getPhpType();
|
||||
}
|
||||
|
||||
if (isset($definitionComplexTypes[$type])) {
|
||||
if ($isArray) {
|
||||
$array = array();
|
||||
|
||||
foreach ($message[$i]->item as $complexType) {
|
||||
$array[] = $this->getInstanceOfType($type, $complexType, $definitionComplexTypes);
|
||||
}
|
||||
|
||||
$message[$i] = $array;
|
||||
} else {
|
||||
$message[$i] = $this->getInstanceOfType($type, $message[$i], $definitionComplexTypes);
|
||||
}
|
||||
} elseif ($isArray) {
|
||||
$message[$i] = $message[$i]->item;
|
||||
}
|
||||
|
||||
$result[$argument->getName()] = $message[$i];
|
||||
$result[$argument->getName()] = $this->processType($argument->getType()->getPhpType(), $message[$i]);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->definitionComplexTypes = array();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getInstanceOfType($type, $message, array $definitionComplexTypes)
|
||||
private function processType($phpType, $message)
|
||||
{
|
||||
$typeClass = $type;
|
||||
$instanceType = new $typeClass();
|
||||
if (preg_match('/^([^\[]+)\[\]$/', $phpType, $match)) {
|
||||
$isArray = true;
|
||||
$type = $match[1];
|
||||
} else {
|
||||
$isArray = false;
|
||||
$type = $phpType;
|
||||
}
|
||||
|
||||
foreach ($definitionComplexTypes[$type] as $type) {
|
||||
if ($type instanceof PropertyComplexType) {
|
||||
if (isset($definitionComplexTypes[$type->getValue()])) {
|
||||
$value = $this->getInstanceOfType($type->getValue(), $message->{$type->getName()}, $definitionComplexTypes);
|
||||
} else {
|
||||
$value = $message->{$type->getName()};
|
||||
if (isset($this->definitionComplexTypes[$type])) {
|
||||
if ($isArray) {
|
||||
$array = array();
|
||||
|
||||
foreach ($message->item as $complexType) {
|
||||
$array[] = $this->getInstanceOfType($type, $complexType);
|
||||
}
|
||||
|
||||
$message = $array;
|
||||
} else {
|
||||
$message = $this->getInstanceOfType($type, $message);
|
||||
}
|
||||
} elseif ($isArray) {
|
||||
$message = $message->item;
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
private function getInstanceOfType($phpType, $message)
|
||||
{
|
||||
$instanceType = new $phpType();
|
||||
|
||||
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
||||
$value = $this->processType($type->getValue(), $message->{$type->getName()});
|
||||
|
||||
if ($type instanceof PropertyComplexType) {
|
||||
$instanceType->{$type->getOriginalName()} = $value;
|
||||
} elseif ($type instanceof MethodComplexType) {
|
||||
if (!$type->getSetter()) {
|
||||
throw new \LogicException();
|
||||
}
|
||||
|
||||
if (isset($definitionComplexTypes[$type->getValue()])) {
|
||||
$value = $this->getInstanceOfType($type->getValue(), $message->{$type->getName()}, $definitionComplexTypes);
|
||||
} else {
|
||||
$value = $message->{$type->getName()};
|
||||
}
|
||||
|
||||
$instanceType->{$type->getSetter()}($value);
|
||||
} else {
|
||||
throw new \InvalidArgumentException();
|
||||
|
|
Loading…
Reference in New Issue