From 429352ac1912bbb3e2503f382ef3d9df647fd1a7 Mon Sep 17 00:00:00 2001 From: Damien Deconinck Date: Thu, 12 Jun 2014 11:11:40 +0200 Subject: [PATCH] implement complexType attribute --- .../ServiceDefinition/Annotation/ComplexType.php | 11 +++++++++++ .../SoapBundle/ServiceDefinition/ComplexType.php | 11 +++++++++++ .../Loader/AnnotationClassLoader.php | 2 +- .../Loader/AnnotationComplexTypeLoader.php | 1 + src/BeSimple/SoapCommon/Definition/Message.php | 4 ++-- src/BeSimple/SoapCommon/Definition/Part.php | 9 ++++++++- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php index 85072d47..7a11238a 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php @@ -18,6 +18,7 @@ class ComplexType extends Configuration private $name; private $value; private $isNillable = false; + private $tagType = 'element'; public function getName() { @@ -34,6 +35,11 @@ public function isNillable() return $this->isNillable; } + public function getTagType() + { + return $this->tagType; + } + public function setName($name) { $this->name = $name; @@ -49,6 +55,11 @@ public function setNillable($isNillable) $this->isNillable = (bool) $isNillable; } + public function setTagType($tagType) + { + $this->tagType = $tagType; + } + public function getAliasName() { return 'complextype'; diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php index d0ae4647..78c5663c 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php @@ -20,6 +20,7 @@ class ComplexType private $name; private $value; private $isNillable = false; + private $tagType = 'element'; public function getName() { @@ -36,6 +37,11 @@ public function isNillable() return $this->isNillable; } + public function getTagType() + { + return $this->tagType; + } + public function setName($name) { $this->name = $name; @@ -50,4 +56,9 @@ public function setNillable($isNillable) { $this->isNillable = (bool) $isNillable; } + + public function setTagType($tagType) + { + $this->tagType = $tagType; + } } diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php index dcd15002..8315b51e 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php @@ -155,7 +155,7 @@ private function loadType($phpType) $loaded = $complexTypeResolver->load($phpType); $complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType); foreach ($loaded['properties'] as $name => $property) { - $complexType->add($name, $this->loadType($property->getValue()), $property->isNillable()); + $complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->getTagType()); } $this->typeRepository->addComplexType($complexType); diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php index 1d3e095e..c3ea0bec 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php @@ -59,6 +59,7 @@ public function load($class, $type = null) $propertyComplexType->setValue($complexType->getValue()); $propertyComplexType->setNillable($complexType->isNillable()); $propertyComplexType->setName($property->getName()); + $propertyComplexType->setTagType($complexType->getTagType()); $annotations['properties']->add($propertyComplexType); } } diff --git a/src/BeSimple/SoapCommon/Definition/Message.php b/src/BeSimple/SoapCommon/Definition/Message.php index caa78fe2..a79bc136 100644 --- a/src/BeSimple/SoapCommon/Definition/Message.php +++ b/src/BeSimple/SoapCommon/Definition/Message.php @@ -48,13 +48,13 @@ public function isEmpty() return 0 === count($this->parts) ? true : false; } - public function add($name, $phpType, $nillable = false) + public function add($name, $phpType, $nillable = false, $tagType = 'element') { if ($phpType instanceof TypeInterface) { $phpType = $phpType->getPhpType(); } - $this->parts[$name] = new Part($name, $phpType, $nillable); + $this->parts[$name] = new Part($name, $phpType, $nillable, $tagType); return $this; } diff --git a/src/BeSimple/SoapCommon/Definition/Part.php b/src/BeSimple/SoapCommon/Definition/Part.php index 317f0464..ac4c3dfd 100644 --- a/src/BeSimple/SoapCommon/Definition/Part.php +++ b/src/BeSimple/SoapCommon/Definition/Part.php @@ -20,12 +20,14 @@ class Part protected $name; protected $type; protected $nillable; + protected $tagType; - public function __construct($name, $type, $nillable = false) + public function __construct($name, $type, $nillable = false, $tagType) { $this->name = $name; $this->type = $type; $this->setNillable($nillable); + $this->tagType = $tagType; } public function getName() @@ -52,4 +54,9 @@ public function setNillable($nillable) { $this->nillable = (boolean) $nillable; } + + public function getTagType() + { + return $this->tagType; + } }