The bundle is back!
The definition of service has changed, read the README.
This commit is contained in:
30
ServiceDefinition/Annotation/Configuration.php
Normal file
30
ServiceDefinition/Annotation/Configuration.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the WebServiceBundle.
|
||||
*
|
||||
* (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 Bundle\WebServiceBundle\ServiceDefinition\Annotation;
|
||||
|
||||
/**
|
||||
* Based on \Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation
|
||||
*
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
abstract class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function __construct(array $values)
|
||||
{
|
||||
foreach ($values as $k => $v) {
|
||||
if (!method_exists($this, $name = 'set'.$k)) {
|
||||
throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, get_class($this)));
|
||||
}
|
||||
|
||||
$this->$name($v);
|
||||
}
|
||||
}
|
||||
}
|
26
ServiceDefinition/Annotation/ConfigurationInterface.php
Normal file
26
ServiceDefinition/Annotation/ConfigurationInterface.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the WebServiceBundle.
|
||||
*
|
||||
* (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 Bundle\WebServiceBundle\ServiceDefinition\Annotation;
|
||||
|
||||
/**
|
||||
* Based on \Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface
|
||||
*
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
interface ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* Returns the alias name for an annotated configuration.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getAliasName();
|
||||
}
|
@ -10,24 +10,36 @@
|
||||
|
||||
namespace Bundle\WebServiceBundle\ServiceDefinition\Annotation;
|
||||
|
||||
class Method
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class Method extends Configuration
|
||||
{
|
||||
private $name;
|
||||
private $value;
|
||||
private $service;
|
||||
|
||||
public function __construct($values)
|
||||
public function getValue()
|
||||
{
|
||||
$this->name = isset($values['value']) ? $values['value'] : null;
|
||||
$this->service = isset($values['service']) ? $values['service'] : null;
|
||||
}
|
||||
|
||||
public function getName($default = null)
|
||||
{
|
||||
return $this->name !== null ? $this->name : $default;
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getService()
|
||||
{
|
||||
return $this->service;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function setService($service)
|
||||
{
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
public function getAliasName()
|
||||
{
|
||||
return 'method';
|
||||
}
|
||||
}
|
@ -10,19 +10,47 @@
|
||||
|
||||
namespace Bundle\WebServiceBundle\ServiceDefinition\Annotation;
|
||||
|
||||
class Param extends TypedElement
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class Param extends Configuration implements TypedElementInterface
|
||||
{
|
||||
private $name;
|
||||
private $value;
|
||||
private $phpType;
|
||||
private $xmlType;
|
||||
|
||||
public function __construct($values)
|
||||
public function getValue()
|
||||
{
|
||||
parent::__construct($values);
|
||||
|
||||
$this->name = $values['value'];
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
public function getPhpType()
|
||||
{
|
||||
return $this->name;
|
||||
return $this->phpType;
|
||||
}
|
||||
|
||||
public function getXmlType()
|
||||
{
|
||||
return $this->xmlType;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function setPhpType($phpType)
|
||||
{
|
||||
$this->phpType = $phpType;
|
||||
}
|
||||
|
||||
public function setXmlType($xmlType)
|
||||
{
|
||||
$this->xmlType = $xmlType;
|
||||
}
|
||||
|
||||
public function getAliasName()
|
||||
{
|
||||
return 'param';
|
||||
}
|
||||
}
|
@ -10,10 +10,36 @@
|
||||
|
||||
namespace Bundle\WebServiceBundle\ServiceDefinition\Annotation;
|
||||
|
||||
class Result extends TypedElement
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class Result extends Configuration implements TypedElementInterface
|
||||
{
|
||||
public function __construct($values)
|
||||
private $phpType;
|
||||
private $xmlType;
|
||||
|
||||
public function getPhpType()
|
||||
{
|
||||
parent::__construct($values);
|
||||
return $this->phpType;
|
||||
}
|
||||
|
||||
public function getXmlType()
|
||||
{
|
||||
return $this->xmlType;
|
||||
}
|
||||
|
||||
public function setPhpType($phpType)
|
||||
{
|
||||
$this->phpType = $phpType;
|
||||
}
|
||||
|
||||
public function setXmlType($xmlType)
|
||||
{
|
||||
$this->xmlType = $xmlType;
|
||||
}
|
||||
|
||||
public function getAliasName()
|
||||
{
|
||||
return 'result';
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the WebServiceBundle.
|
||||
*
|
||||
* (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 Bundle\WebServiceBundle\ServiceDefinition\Annotation;
|
||||
|
||||
abstract class TypedElement
|
||||
{
|
||||
private $phpType;
|
||||
private $xmlType;
|
||||
|
||||
public function __construct($values)
|
||||
{
|
||||
foreach(array('type', 'phpType') as $key)
|
||||
{
|
||||
if(isset($values[$key]))
|
||||
{
|
||||
$this->phpType = $values[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$this->xmlType = isset($values['xmlType']) ? $values['xmlType'] : null;
|
||||
}
|
||||
|
||||
public function getPhpType()
|
||||
{
|
||||
return $this->phpType;
|
||||
}
|
||||
|
||||
public function getXmlType()
|
||||
{
|
||||
return $this->xmlType;
|
||||
}
|
||||
}
|
19
ServiceDefinition/Annotation/TypedElementInterface.php
Normal file
19
ServiceDefinition/Annotation/TypedElementInterface.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the WebServiceBundle.
|
||||
*
|
||||
* (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 Bundle\WebServiceBundle\ServiceDefinition\Annotation;
|
||||
|
||||
interface TypedElementInterface
|
||||
{
|
||||
function getPhpType();
|
||||
function getXmlType();
|
||||
function setPhpType($phpType);
|
||||
function setXmlType($xmlType);
|
||||
}
|
Reference in New Issue
Block a user