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:
@ -23,14 +23,13 @@ Controller
|
||||
/**
|
||||
* @Soap\Method("getUser")
|
||||
* @Soap\Param("name", phpType = "string")
|
||||
*
|
||||
* Specify \My\App\Entity\User phpType
|
||||
* Warning: Do not forget the first backslash
|
||||
* @Soap\Result(phpType = "\My\App\Entity\User")
|
||||
* @Soap\Result(phpType = "My\App\Entity\User")
|
||||
*/
|
||||
public function getUserAction($name)
|
||||
{
|
||||
$user = $this->container->getDoctrine()->getRepository('MyApp:User')->findOneByName($name);
|
||||
$user = $this->container->getDoctrine()->getRepository('MyApp:User')->findOneBy(array(
|
||||
'name' => $name,
|
||||
);
|
||||
|
||||
if (!$user) {
|
||||
throw new \SoapFault('USER_NOT_FOUND', sprintf('The user with the name "%s" can not be found', $name));
|
||||
@ -43,7 +42,7 @@ Controller
|
||||
User class
|
||||
----------
|
||||
|
||||
You can expose public property and public method (getter and setter).
|
||||
You can expose only the properties (public, protected or private) of a complex type.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
@ -54,67 +53,34 @@ You can expose public property and public method (getter and setter).
|
||||
class User
|
||||
{
|
||||
/**
|
||||
* @Soap\PropertyComplexType("string")
|
||||
* @Soap\ComplexType("string")
|
||||
*/
|
||||
public $firstname;
|
||||
|
||||
/**
|
||||
* @Soap\PropertyComplexType("string")
|
||||
* @Soap\ComplexType("string")
|
||||
*/
|
||||
public $lastname;
|
||||
|
||||
/**
|
||||
* @Soap\ComplexType("int", nillable=true)
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @Soap\ComplexType("string")
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @Soap\ComplexType("string")
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @Soap\MethodComplexType("int", name="user_id", nillable=true)
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Soap\MethodComplexType("string", setter="setUsername")
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Soap\MethodComplexType("string", setter="setEmail")
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setUsername($username)
|
||||
{
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
}
|
||||
}
|
||||
|
||||
PropertyComplexType
|
||||
-------------------
|
||||
ComplexType
|
||||
-----------
|
||||
|
||||
`PropertyComplexType` accepts the following options:
|
||||
`ComplexType` accepts the following options:
|
||||
|
||||
* **name**: To override the original name of the property
|
||||
* **nillable**: To specify that the value can be null
|
||||
|
||||
MethodComplexType
|
||||
-------------------
|
||||
|
||||
`MethodComplexType` accepts the following options:
|
||||
|
||||
* **name**: To override the original name of the property
|
||||
* **nillable**: To specify that the value can be null
|
||||
* **setter**: The set method name value. *Mandatory if the complex type is passed as a parameter to a function.*
|
||||
* nillable: To specify that the value can be null
|
Reference in New Issue
Block a user