Add minOccurs annotation support on complexType
This commit is contained in:
parent
30850d7a01
commit
e024833d48
|
@ -18,6 +18,7 @@ class ComplexType extends Configuration
|
|||
private $name;
|
||||
private $value;
|
||||
private $isNillable = false;
|
||||
private $minOccurs = 1;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
|
@ -34,6 +35,11 @@ class ComplexType extends Configuration
|
|||
return $this->isNillable;
|
||||
}
|
||||
|
||||
public function getIsNillable()
|
||||
{
|
||||
return $this->isNillable;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
@ -49,6 +55,21 @@ class ComplexType extends Configuration
|
|||
$this->isNillable = (bool) $isNillable;
|
||||
}
|
||||
|
||||
public function setIsNillable($isNillable)
|
||||
{
|
||||
$this->isNillable = (bool) $isNillable;
|
||||
}
|
||||
|
||||
public function setMinOccurs($minOccurs)
|
||||
{
|
||||
$this->minOccurs = $minOccurs;
|
||||
}
|
||||
|
||||
public function getMinOccurs()
|
||||
{
|
||||
return $this->minOccurs;
|
||||
}
|
||||
|
||||
public function getAliasName()
|
||||
{
|
||||
return 'complextype';
|
||||
|
|
|
@ -20,6 +20,7 @@ class ComplexType
|
|||
private $name;
|
||||
private $value;
|
||||
private $isNillable = false;
|
||||
private $minOccurs = 1;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
|
@ -50,4 +51,14 @@ class ComplexType
|
|||
{
|
||||
$this->isNillable = (bool) $isNillable;
|
||||
}
|
||||
|
||||
public function setMinOccurs($minOccurs)
|
||||
{
|
||||
$this->minOccurs = $minOccurs;
|
||||
}
|
||||
|
||||
public function getMinOccurs()
|
||||
{
|
||||
return $this->minOccurs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
|||
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
||||
}
|
||||
|
||||
$annotations = array();
|
||||
$annotations = [];
|
||||
|
||||
$class = new \ReflectionClass($class);
|
||||
if ($alias = $this->reader->getClassAnnotation($class, $this->aliasClass)) {
|
||||
|
@ -59,6 +59,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
|||
$propertyComplexType->setValue($complexType->getValue());
|
||||
$propertyComplexType->setNillable($complexType->isNillable());
|
||||
$propertyComplexType->setName($property->getName());
|
||||
$propertyComplexType->setMinOccurs($complexType->getMinOccurs());
|
||||
$annotations['properties']->add($propertyComplexType);
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +73,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
|||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return Boolean True if this class supports the given resource, false otherwise
|
||||
* @return bool True if this class supports the given resource, false otherwise
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ class Message
|
|||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->parts = array();
|
||||
$this->parts = [];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
@ -48,13 +48,13 @@ class Message
|
|||
return 0 === count($this->parts) ? true : false;
|
||||
}
|
||||
|
||||
public function add($name, $phpType, $nillable = false)
|
||||
public function add($name, $phpType, $nillable = false, $minOccurs = 1)
|
||||
{
|
||||
if ($phpType instanceof TypeInterface) {
|
||||
$phpType = $phpType->getPhpType();
|
||||
}
|
||||
|
||||
$this->parts[$name] = new Part($name, $phpType, $nillable);
|
||||
$this->parts[$name] = new Part($name, $phpType, $nillable, $minOccurs);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -20,11 +20,13 @@ class Part
|
|||
protected $name;
|
||||
protected $type;
|
||||
protected $nillable;
|
||||
protected $minOccurs;
|
||||
|
||||
public function __construct($name, $type, $nillable = false)
|
||||
public function __construct($name, $type, $nillable = false, $minOccurs = 1)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
$this->minOccurs = $minOccurs;
|
||||
$this->setNillable($nillable);
|
||||
}
|
||||
|
||||
|
@ -50,6 +52,16 @@ class Part
|
|||
|
||||
public function setNillable($nillable)
|
||||
{
|
||||
$this->nillable = (boolean) $nillable;
|
||||
$this->nillable = (bool) $nillable;
|
||||
}
|
||||
|
||||
public function setMinOccurs($minOccurs)
|
||||
{
|
||||
$this->minOccurs = $minOccurs;
|
||||
}
|
||||
|
||||
public function getMinOccurs()
|
||||
{
|
||||
return $this->minOccurs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class Dumper
|
|||
protected $domService;
|
||||
protected $domPortType;
|
||||
|
||||
public function __construct(Definition $definition, array $options = array())
|
||||
public function __construct(Definition $definition, array $options = [])
|
||||
{
|
||||
$this->definition = $definition;
|
||||
$this->document = new \DOMDocument('1.0', 'utf-8');
|
||||
|
@ -64,15 +64,15 @@ class Dumper
|
|||
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
$this->options = array(
|
||||
$this->options = [
|
||||
'version11_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version11',
|
||||
'version12_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version12',
|
||||
'version11_name' => $this->definition->getName(),
|
||||
'version12_name' => $this->definition->getName() . '12',
|
||||
'stylesheet' => null,
|
||||
);
|
||||
];
|
||||
|
||||
$invalid = array();
|
||||
$invalid = [];
|
||||
foreach ($options as $key => $value) {
|
||||
if (array_key_exists($key, $this->options)) {
|
||||
$this->options[$key] = $value;
|
||||
|
@ -114,7 +114,7 @@ class Dumper
|
|||
$this->addMethods();
|
||||
$this->addService();
|
||||
|
||||
foreach (array($this->version11, $this->version12) as $version) {
|
||||
foreach ([$this->version11, $this->version12] as $version) {
|
||||
if (!$version) {
|
||||
continue;
|
||||
}
|
||||
|
@ -265,6 +265,12 @@ class Dumper
|
|||
$element->setAttribute('maxOccurs', 'unbounded');
|
||||
}
|
||||
|
||||
// 1 is the default value of minOccurs.
|
||||
if (1 != $child->getMinOccurs()) {
|
||||
$element->setAttribute('minOccurs', $child->getMinOccurs());
|
||||
$element->setAttribute('maxOccurs', 'unbounded');
|
||||
}
|
||||
|
||||
$all->appendChild($element);
|
||||
}
|
||||
|
||||
|
@ -284,7 +290,7 @@ class Dumper
|
|||
$operation = $this->document->createElement('operation');
|
||||
$operation->setAttribute('name', $method->getName());
|
||||
|
||||
foreach (array('input' => $method->getInput(), 'output' => $method->getOutput(), 'fault' => $method->getFault()) as $type => $message) {
|
||||
foreach (['input' => $method->getInput(), 'output' => $method->getOutput(), 'fault' => $method->getFault()] as $type => $message) {
|
||||
if ('fault' === $type && $message->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue