|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace WsdlToPhp\PackageGenerator\Container\Model; |
|
4
|
|
|
|
|
5
|
|
|
use WsdlToPhp\PackageGenerator\Model\Service as Model; |
|
6
|
|
|
use WsdlToPhp\PackageGenerator\Model\Method as MethodModel; |
|
7
|
|
|
|
|
8
|
|
|
class Service extends AbstractModel |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @see \WsdlToPhp\PackageGenerator\Container\Model\Model::objectClass() |
|
12
|
|
|
* @return string |
|
13
|
|
|
*/ |
|
14
|
655 |
|
protected function objectClass() |
|
15
|
|
|
{ |
|
16
|
655 |
|
return 'WsdlToPhp\PackageGenerator\Model\Service'; |
|
17
|
|
|
} |
|
18
|
|
|
/** |
|
19
|
|
|
* Adds a service |
|
20
|
|
|
* @param string $serviceName the service name to which add the method |
|
21
|
|
|
* @param string $methodName the original function name |
|
22
|
|
|
* @param string|array $methodParameter the original parameter name |
|
23
|
|
|
* @param string|array $methodReturn the original return name |
|
24
|
|
|
* @return Service |
|
25
|
|
|
*/ |
|
26
|
275 |
|
public function addService($serviceName, $methodName, $methodParameter, $methodReturn) |
|
27
|
|
|
{ |
|
28
|
275 |
|
if (!$this->get($serviceName) instanceof Model) { |
|
29
|
270 |
|
$this->add(new Model($this->generator, $serviceName)); |
|
30
|
162 |
|
} |
|
31
|
275 |
|
$serviceMethod = $this->get($serviceName)->getMethod($methodName); |
|
32
|
|
|
/** |
|
33
|
|
|
* Service method does not already exist, register it |
|
34
|
|
|
*/ |
|
35
|
275 |
|
if (!$serviceMethod instanceof MethodModel) { |
|
36
|
275 |
|
$this->get($serviceName)->addMethod($methodName, $methodParameter, $methodReturn); |
|
37
|
191 |
|
} elseif ($serviceMethod->getParameterType() != $methodParameter) { |
|
38
|
|
|
/** |
|
39
|
|
|
* Service method exists with a different signature, register it too by identifying the service functions as non unique functions |
|
40
|
|
|
*/ |
|
41
|
5 |
|
$serviceMethod->setUnique(false); |
|
42
|
5 |
|
$this->get($serviceName)->addMethod($methodName, $methodParameter, $methodReturn, false); |
|
43
|
3 |
|
} |
|
44
|
275 |
|
return $this; |
|
45
|
|
|
} |
|
46
|
|
|
/** |
|
47
|
|
|
* @param string $name |
|
48
|
|
|
* @return Model|null |
|
49
|
|
|
*/ |
|
50
|
195 |
|
public function getServiceByName($name) |
|
51
|
|
|
{ |
|
52
|
195 |
|
return $this->get($name); |
|
53
|
|
|
} |
|
54
|
|
|
/** |
|
55
|
|
|
* @see \WsdlToPhp\PackageGenerator\Model\AbstractModel::get() |
|
56
|
|
|
* @param string $value |
|
57
|
|
|
* @return Model|null |
|
58
|
|
|
*/ |
|
59
|
370 |
|
public function get($value) |
|
60
|
|
|
{ |
|
61
|
370 |
|
return parent::get($value); |
|
62
|
|
|
} |
|
63
|
|
|
/** |
|
64
|
|
|
* @return MethodModel[] |
|
65
|
|
|
*/ |
|
66
|
10 |
|
public function getMethods() |
|
67
|
|
|
{ |
|
68
|
10 |
|
$methods = new Method($this->generator); |
|
69
|
10 |
|
foreach ($this->objects as $service) { |
|
70
|
10 |
|
foreach ($service->getMethods() as $method) { |
|
71
|
10 |
|
$methods->add($method); |
|
72
|
6 |
|
} |
|
73
|
6 |
|
} |
|
74
|
10 |
|
return $methods; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|