Updated definition of ComplexType and use classmap option of SoapServer
Please to refer to the documentation for the changes: http://besim.pl/SoapBundle/tutorial/complex_type.html
This commit is contained in:
@ -13,7 +13,7 @@ namespace BeSimple\SoapBundle\ServiceDefinition\Annotation;
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class PropertyComplexType extends Configuration
|
||||
class ComplexType extends Configuration
|
||||
{
|
||||
private $name;
|
||||
private $value;
|
||||
@ -51,6 +51,6 @@ class PropertyComplexType extends Configuration
|
||||
|
||||
public function getAliasName()
|
||||
{
|
||||
return 'propertycomplextype';
|
||||
return 'complextype';
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the BeSimpleSoapBundle.
|
||||
*
|
||||
* (c) Christian Kerl <christian-kerl@web.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace BeSimple\SoapBundle\ServiceDefinition\Annotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class MethodComplexType extends Configuration
|
||||
{
|
||||
private $name;
|
||||
private $value;
|
||||
private $setter;
|
||||
private $isNillable = false;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getSetter()
|
||||
{
|
||||
return $this->setter;
|
||||
}
|
||||
|
||||
public function isNillable()
|
||||
{
|
||||
return $this->isNillable;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function setSetter($setter)
|
||||
{
|
||||
$this->setter = $setter;
|
||||
}
|
||||
|
||||
public function setNillable($isNillable)
|
||||
{
|
||||
$this->isNillable = (bool) $isNillable;
|
||||
}
|
||||
|
||||
public function getAliasName()
|
||||
{
|
||||
return 'methodcomplextype';
|
||||
}
|
||||
}
|
@ -8,15 +8,14 @@
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace BeSimple\SoapBundle\ServiceDefinition\Strategy;
|
||||
namespace BeSimple\SoapBundle\ServiceDefinition;
|
||||
|
||||
/**
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
abstract class BaseComplexType
|
||||
class ComplexType
|
||||
{
|
||||
private $name;
|
||||
private $originalName;
|
||||
private $value;
|
||||
private $isNillable = false;
|
||||
|
||||
@ -25,11 +24,6 @@ abstract class BaseComplexType
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getOriginalName()
|
||||
{
|
||||
return $this->originalName ?: $this->name;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
@ -45,11 +39,6 @@ abstract class BaseComplexType
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function setOriginalName($originalName)
|
||||
{
|
||||
$this->originalName = $originalName;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
@ -10,9 +10,7 @@
|
||||
|
||||
namespace BeSimple\SoapBundle\ServiceDefinition\Loader;
|
||||
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation\ComplexType;
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType;
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType;
|
||||
use BeSimple\SoapBundle\ServiceDefinition\ComplexType;
|
||||
use BeSimple\SoapBundle\Util\Collection;
|
||||
|
||||
/**
|
||||
@ -24,8 +22,7 @@ use BeSimple\SoapBundle\Util\Collection;
|
||||
*/
|
||||
class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
||||
{
|
||||
private $propertyComplexTypeClass = 'BeSimple\SoapBundle\ServiceDefinition\Annotation\PropertyComplexType';
|
||||
private $methodComplexTypeClass = 'BeSimple\SoapBundle\ServiceDefinition\Annotation\MethodComplexType';
|
||||
private $complexTypeClass = 'BeSimple\SoapBundle\ServiceDefinition\Annotation\ComplexType';
|
||||
|
||||
/**
|
||||
* Loads a ServiceDefinition from annotations from a class.
|
||||
@ -44,48 +41,17 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
||||
}
|
||||
|
||||
$class = new \ReflectionClass($class);
|
||||
$collection = new Collection('getName');
|
||||
$collection = new Collection('getName', 'BeSimple\SoapBundle\ServiceDefinition\ComplexType');
|
||||
|
||||
foreach ($class->getProperties() as $property) {
|
||||
if ($property->isPublic()) {
|
||||
$complexType = $this->reader->getPropertyAnnotation($property, $this->propertyComplexTypeClass);
|
||||
$complexType = $this->reader->getPropertyAnnotation($property, $this->complexTypeClass);
|
||||
|
||||
if ($complexType) {
|
||||
$propertyComplexType = new PropertyComplexType();
|
||||
$propertyComplexType->setValue($complexType->getValue());
|
||||
$propertyComplexType->setNillable($complexType->isNillable());
|
||||
|
||||
if (!$complexType->getName()) {
|
||||
$propertyComplexType->setName($property->getName());
|
||||
} else {
|
||||
$propertyComplexType->setName($complexType->getName());
|
||||
$propertyComplexType->setOriginalName($property->getName());
|
||||
}
|
||||
|
||||
$collection->add($propertyComplexType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($class->getMethods() as $method) {
|
||||
if ($method->isPublic()) {
|
||||
$complexType = $this->reader->getMethodAnnotation($method, $this->methodComplexTypeClass);
|
||||
|
||||
if ($complexType) {
|
||||
$methodComplexType = new MethodComplexType();
|
||||
$methodComplexType->setValue($complexType->getValue());
|
||||
$methodComplexType->setSetter($complexType->getSetter());
|
||||
$methodComplexType->setNillable($complexType->isNillable());
|
||||
|
||||
if (!$complexType->getName()) {
|
||||
$methodComplexType->setName($property->getName());
|
||||
} else {
|
||||
$methodComplexType->setName($complexType->getName());
|
||||
$methodComplexType->setOriginalName($method->getName());
|
||||
}
|
||||
|
||||
$collection->add($methodComplexType);
|
||||
}
|
||||
if ($complexType) {
|
||||
$propertyComplexType = new ComplexType();
|
||||
$propertyComplexType->setValue($complexType->getValue());
|
||||
$propertyComplexType->setNillable($complexType->isNillable());
|
||||
$propertyComplexType->setName($property->getName());
|
||||
$collection->add($propertyComplexType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the BeSimpleSoapBundle.
|
||||
*
|
||||
* (c) Christian Kerl <christian-kerl@web.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace BeSimple\SoapBundle\ServiceDefinition\Strategy;
|
||||
|
||||
/**
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
class MethodComplexType extends BaseComplexType
|
||||
{
|
||||
private $setter;
|
||||
|
||||
public function getSetter()
|
||||
{
|
||||
return $this->setter;
|
||||
}
|
||||
|
||||
public function setSetter($setter)
|
||||
{
|
||||
$this->setter = $setter;
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the BeSimpleSoapBundle.
|
||||
*
|
||||
* (c) Christian Kerl <christian-kerl@web.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace BeSimple\SoapBundle\ServiceDefinition\Strategy;
|
||||
|
||||
/**
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
class PropertyComplexType extends BaseComplexType
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user