From 6de878de7d7ae4a916258fdf79374c6720ff6d08 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Mon, 22 Jul 2013 20:34:25 +0200 Subject: [PATCH] [SoapBundle] Fixed ComplexType strategy to find Type by Classname --- .../Resources/config/webservice.xml | 2 +- .../Strategy/ComplexType.php | 35 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/BeSimple/SoapBundle/Resources/config/webservice.xml b/src/BeSimple/SoapBundle/Resources/config/webservice.xml index 122cd86..cd1a689 100644 --- a/src/BeSimple/SoapBundle/Resources/config/webservice.xml +++ b/src/BeSimple/SoapBundle/Resources/config/webservice.xml @@ -15,7 +15,7 @@ BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedResponseMessageBinder BeSimple\SoapBundle\ServiceDefinition\Dumper\WsdlDumper BeSimple\SoapBundle\Converter\TypeRepository - BeSimple\SoapCommon\Classmap + BeSimple\SoapServer\Classmap diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Strategy/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/Strategy/ComplexType.php index 6be1228..0e0b579 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Strategy/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Strategy/ComplexType.php @@ -36,51 +36,50 @@ class ComplexType extends AbstractComplexTypeStrategy * @param string $type Name of the class to be specified * @return string XSD Type for the given PHP type */ - public function addComplexType($type) + public function addComplexType($classname) { // Really needed? - if (null !== $soapType = $this->scanRegisteredTypes($type)) { - return $soapType; + if (null !== $type = $this->scanRegisteredTypes($classname)) { + return $type; } $classmap = $this->definition->getClassmap(); - if ($classmap->has($type)) { - $xmlName = $classmap->get($type); - $this->addDefinition($type, $xmlName); + if ($classmap->hasByClassname($classname)) { + $type = $classmap->getByClassname($classname); - $xmlType = 'tns:'.$xmlName; + $xmlType = 'tns:'.$type; } else { - if (!$this->loader->supports($type)) { - throw new \InvalidArgumentException(sprintf('Cannot add a complex type "%s" that is not an object or where class could not be found in "ComplexType" strategy.', $type)); + if (!$this->loader->supports($classname)) { + throw new \InvalidArgumentException(sprintf('Cannot add a complex type "%s" that is not an object or where class could not be found in "ComplexType" strategy.', $classname)); } - $xmlName = $this->getContext()->translateType($type); - $xmlType = 'tns:'.$xmlName; + $type = $this->getContext()->translateType($classname); + $xmlType = 'tns:'.$type; // Register type here to avoid recursion - $classmap->add($type, $xmlName); - $this->getContext()->addType($type, $soapType); + $classmap->add($type, $classname); + $this->getContext()->addType($classname, $xmlType); } - $this->addDefinition($type, $xmlName); + $this->addXmlDefinition($classname, $type); return $xmlType; } - private function addDefinition($type, $xmlName) + private function addXmlDefinition($classname, $type) { - if ($this->definition->hasDefinitionComplexType($type)) { + if ($this->definition->hasDefinitionComplexType($classname)) { return false; } $dom = $this->getContext()->toDomDocument(); $complexType = $dom->createElement('xsd:complexType'); - $complexType->setAttribute('name', $xmlName); + $complexType->setAttribute('name', $type); $all = $dom->createElement('xsd:all'); $elements = array(); - $definitionComplexType = $this->loader->load($type); + $definitionComplexType = $this->loader->load($classname); foreach ($definitionComplexType as $annotationComplexType) { $element = $dom->createElement('xsd:element'); $element->setAttribute('name', $annotationComplexType->getName());