|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace WsdlToPhp\PackageGenerator\Model; |
|
4
|
|
|
|
|
5
|
|
|
use WsdlToPhp\PackageGenerator\Generator\Utils; |
|
6
|
|
|
use WsdlToPhp\PackageGenerator\Container\Model\Method as MethodContainer; |
|
7
|
|
|
use WsdlToPhp\PackageGenerator\Generator\Generator; |
|
8
|
|
|
use WsdlToPhp\PackageGenerator\ConfigurationReader\ServiceReservedMethod; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class Service stands for an available service containing the methods/operations described in the WSDL |
|
12
|
|
|
*/ |
|
13
|
|
|
class Service extends AbstractModel |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var string |
|
17
|
|
|
*/ |
|
18
|
|
|
const DEFAULT_SERVICE_CLASS_NAME = 'Service'; |
|
19
|
|
|
/** |
|
20
|
|
|
* Store the methods of the service |
|
21
|
|
|
* @var MethodContainer |
|
22
|
|
|
*/ |
|
23
|
|
|
private $methods; |
|
24
|
|
|
/** |
|
25
|
|
|
* Main constructor |
|
26
|
|
|
* @see AbstractModel::__construct() |
|
27
|
|
|
* @uses Service::setMethods() |
|
28
|
|
|
* @param Generator $generator |
|
29
|
|
|
* @param string $name the service name |
|
30
|
500 |
|
*/ |
|
31
|
|
|
public function __construct(Generator $generator, $name) |
|
32
|
500 |
|
{ |
|
33
|
500 |
|
parent::__construct($generator, $name); |
|
34
|
500 |
|
$this->setMethods(new MethodContainer($generator)); |
|
35
|
|
|
} |
|
36
|
|
|
/** |
|
37
|
|
|
* Returns the contextual part of the class name for the package |
|
38
|
|
|
* @see AbstractModel::getContextualPart() |
|
39
|
|
|
* @return string |
|
40
|
496 |
|
*/ |
|
41
|
|
|
public function getContextualPart() |
|
42
|
496 |
|
{ |
|
43
|
|
|
return $this->getGenerator()->getOptionServicesFolder(); |
|
44
|
|
|
} |
|
45
|
|
|
/** |
|
46
|
|
|
* Returns the sub package name which the model belongs to |
|
47
|
|
|
* Must be overridden by sub classes |
|
48
|
|
|
* @see AbstractModel::getDocSubPackages() |
|
49
|
|
|
* @return array |
|
50
|
84 |
|
*/ |
|
51
|
|
|
public function getDocSubPackages() |
|
52
|
|
|
{ |
|
53
|
84 |
|
return array( |
|
54
|
63 |
|
'Services', |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
/** |
|
58
|
|
|
* Returns the methods of the service |
|
59
|
|
|
* @return MethodContainer |
|
60
|
132 |
|
*/ |
|
61
|
|
|
public function getMethods() |
|
62
|
132 |
|
{ |
|
63
|
|
|
return $this->methods; |
|
64
|
|
|
} |
|
65
|
|
|
/** |
|
66
|
|
|
* Sets the methods container |
|
67
|
|
|
* @param MethodContainer $methodContainer |
|
68
|
|
|
* @return Service |
|
69
|
500 |
|
*/ |
|
70
|
|
|
private function setMethods(MethodContainer $methodContainer) |
|
71
|
500 |
|
{ |
|
72
|
500 |
|
$this->methods = $methodContainer; |
|
73
|
|
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
/** |
|
76
|
|
|
* Adds a method to the service |
|
77
|
|
|
* @uses Method::setIsUnique() |
|
78
|
|
|
* @param string $methodName original method name |
|
79
|
|
|
* @param string|array $methodParameterType original parameter type/name |
|
80
|
|
|
* @param string|array $methodReturnType original return type/name |
|
81
|
|
|
* @param bool $methodIsUnique original isUnique value |
|
82
|
|
|
* @return Method |
|
83
|
492 |
|
*/ |
|
84
|
|
|
public function addMethod($methodName, $methodParameterType, $methodReturnType, $methodIsUnique = true) |
|
85
|
492 |
|
{ |
|
86
|
492 |
|
$method = new Method($this->getGenerator(), $methodName, $methodParameterType, $methodReturnType, $this, $methodIsUnique); |
|
87
|
492 |
|
$this->methods->add($method); |
|
88
|
|
|
return $method; |
|
89
|
|
|
} |
|
90
|
|
|
/** |
|
91
|
|
|
* Returns the method by its original name |
|
92
|
|
|
* @uses Service::getMethods() |
|
93
|
|
|
* @uses AbstractModel::getName() |
|
94
|
|
|
* @param string $methodName the original method name |
|
95
|
|
|
* @return Method|null |
|
96
|
496 |
|
*/ |
|
97
|
|
|
public function getMethod($methodName) |
|
98
|
496 |
|
{ |
|
99
|
|
|
return $this->methods->getMethodByName($methodName); |
|
100
|
|
|
} |
|
101
|
|
|
/** |
|
102
|
|
|
* Allows to define from which class the curent model extends |
|
103
|
|
|
* @param bool $short |
|
104
|
|
|
* @return string |
|
105
|
84 |
|
*/ |
|
106
|
|
|
public function getExtends($short = false) |
|
107
|
84 |
|
{ |
|
108
|
84 |
|
$extends = $this->getGenerator()->getOptionSoapClientClass(); |
|
109
|
|
|
return $short ? Utils::removeNamespace($extends) : $extends; |
|
110
|
|
|
} |
|
111
|
|
|
/** |
|
112
|
|
|
* @param $filename |
|
113
|
|
|
* @return ServiceReservedMethod |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getReservedMethodsInstance($filename = null) |
|
116
|
|
|
{ |
|
117
|
|
|
return ServiceReservedMethod::instance($filename); |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|