Skip to content

Commit f6f617c

Browse files
authored
Merge pull request #2 from raziel057/master
Fix issue with "item" for collection of objects
2 parents 4b71c34 + a1fb4c2 commit f6f617c

File tree

8 files changed

+89
-6
lines changed

8 files changed

+89
-6
lines changed

src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ private function processType($phpType, $message)
6868

6969
$message = $array;
7070
} else {
71-
$message = $this->checkComplexType($phpType, $message);
71+
if (is_array($message)) {
72+
foreach ($message as $complexType) {
73+
$array[] = $this->checkComplexType($phpType, $complexType);
74+
}
75+
$message = $array;
76+
} else {
77+
$message = $this->checkComplexType($phpType, $message);
78+
}
7279
}
7380
}
7481

src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class ComplexType extends Configuration
1818
private $name;
1919
private $value;
2020
private $isNillable = false;
21+
private $minOccurs;
22+
private $maxOccurs;
2123

2224
public function getName()
2325
{
@@ -49,8 +51,28 @@ public function setNillable($isNillable)
4951
$this->isNillable = (bool) $isNillable;
5052
}
5153

54+
public function getMinOccurs()
55+
{
56+
return $this->minOccurs;
57+
}
58+
59+
public function setMinOccurs($minOccurs)
60+
{
61+
$this->minOccurs = $minOccurs;
62+
}
63+
64+
public function getMaxOccurs()
65+
{
66+
return $this->maxOccurs;
67+
}
68+
69+
public function setMaxOccurs($maxOccurs)
70+
{
71+
$this->maxOccurs = $maxOccurs;
72+
}
73+
5274
public function getAliasName()
5375
{
5476
return 'complextype';
5577
}
56-
}
78+
}

src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class ComplexType
2020
private $name;
2121
private $value;
2222
private $isNillable = false;
23+
private $minOccurs;
24+
private $maxOccurs;
2325

2426
public function getName()
2527
{
@@ -50,4 +52,23 @@ public function setNillable($isNillable)
5052
{
5153
$this->isNillable = (bool) $isNillable;
5254
}
55+
56+
public function getMinOccurs()
57+
{
58+
return $this->minOccurs;
59+
}
60+
61+
public function setMinOccurs($minOccurs)
62+
{
63+
$this->minOccurs = $minOccurs;
64+
}
65+
public function getMaxOccurs()
66+
{
67+
return $this->maxOccurs;
68+
}
69+
70+
public function setMaxOccurs($maxOccurs)
71+
{
72+
$this->maxOccurs = $maxOccurs;
73+
}
5374
}

src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private function loadType($phpType)
155155
$loaded = $complexTypeResolver->load($phpType);
156156
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
157157
foreach ($loaded['properties'] as $name => $property) {
158-
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable());
158+
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->getMinOccurs(), $property->getMaxOccurs());
159159
}
160160

161161
$this->typeRepository->addComplexType($complexType);

src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public function load($class, $type = null)
5858
$propertyComplexType = new ComplexType();
5959
$propertyComplexType->setValue($complexType->getValue());
6060
$propertyComplexType->setNillable($complexType->isNillable());
61+
$propertyComplexType->setMinOccurs($complexType->getMinOccurs());
62+
$propertyComplexType->setMaxOccurs($complexType->getMaxOccurs());
6163
$propertyComplexType->setName($property->getName());
6264
$annotations['properties']->add($propertyComplexType);
6365
}

src/BeSimple/SoapCommon/Definition/Message.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public function isEmpty()
4848
return 0 === count($this->parts) ? true : false;
4949
}
5050

51-
public function add($name, $phpType, $nillable = false)
51+
public function add($name, $phpType, $nillable = false, $minOccurs = null, $maxOccurs = null)
5252
{
5353
if ($phpType instanceof TypeInterface) {
5454
$phpType = $phpType->getPhpType();
5555
}
5656

57-
$this->parts[$name] = new Part($name, $phpType, $nillable);
57+
$this->parts[$name] = new Part($name, $phpType, $nillable, $minOccurs, $maxOccurs);
5858

5959
return $this;
6060
}

src/BeSimple/SoapCommon/Definition/Part.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ class Part
2020
protected $name;
2121
protected $type;
2222
protected $nillable;
23+
protected $minOccurs;
24+
protected $maxOccurs;
2325

24-
public function __construct($name, $type, $nillable = false)
26+
public function __construct($name, $type, $nillable = false, $minOccurs = null, $maxOccurs = null)
2527
{
2628
$this->name = $name;
2729
$this->type = $type;
2830
$this->setNillable($nillable);
31+
$this->setMinOccurs($minOccurs);
32+
$this->setNillable($maxOccurs);
2933
}
3034

3135
public function getName()
@@ -52,4 +56,24 @@ public function setNillable($nillable)
5256
{
5357
$this->nillable = (boolean) $nillable;
5458
}
59+
60+
public function getMinOccurs()
61+
{
62+
return $this->minOccurs;
63+
}
64+
65+
public function setMinOccurs($minOccurs)
66+
{
67+
$this->minOccurs = $minOccurs;
68+
}
69+
70+
public function getMaxOccurs()
71+
{
72+
return $this->maxOccurs;
73+
}
74+
75+
public function setMaxOccurs($maxOccurs)
76+
{
77+
$this->maxOccurs = $maxOccurs;
78+
}
5579
}

src/BeSimple/SoapWsdl/Dumper/Dumper.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ protected function addComplexType(ComplexType $type)
259259
if ($child->isNillable()) {
260260
$element->setAttribute('nillable', 'true');
261261
}
262+
263+
if (null !== $child->getMinOccurs() && 1 != $child->getMinOccurs()) {
264+
$element->setAttribute('minOccurs', $child->getMinOccurs());
265+
}
266+
if (null !== $child->getMaxOccurs() && 1 != $child->getMaxOccurs()) {
267+
$element->setAttribute('maxOccurs', $child->getMaxOccurs());
268+
}
262269

263270
if ($type instanceof ArrayOfType) {
264271
$element->setAttribute('minOccurs', 0);

0 commit comments

Comments
 (0)