1
|
|
|
<?php |
2
|
|
|
namespace Mezon\Service\ServiceHttpTransport; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Class ServiceHttpTransport |
6
|
|
|
* |
7
|
|
|
* @package Service |
8
|
|
|
* @subpackage ServiceHttpTransport |
9
|
|
|
* @author Dodonov A.A. |
10
|
|
|
* @version v.1.0 (2019/08/13) |
11
|
|
|
* @copyright Copyright (c) 2019, aeon.org |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* HTTP transport for all services |
16
|
|
|
* |
17
|
|
|
* @author Dodonov A.A. |
18
|
|
|
*/ |
19
|
|
|
class ServiceHttpTransport extends \Mezon\Service\ServiceTransport |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Method creates session from existing token or fetched from HTTP headers |
24
|
|
|
* |
25
|
|
|
* @param string $token |
26
|
|
|
* Session token |
27
|
|
|
* @return string Session token |
28
|
|
|
*/ |
29
|
|
|
public function createSession(string $token): string |
30
|
|
|
{ |
31
|
|
|
return $this->getSecurityProvider()->createSession($token); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Method creates parameters fetcher |
36
|
|
|
* |
37
|
|
|
* @return \Mezon\Service\ServiceRequestParamsInterface paremeters fetcher |
38
|
|
|
*/ |
39
|
|
|
public function createFetcher(): \Mezon\Service\ServiceRequestParamsInterface |
40
|
|
|
{ |
41
|
|
|
return new \Mezon\Service\ServiceHttpTransport\HttpRequestParams($this->getRouter()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Method outputs HTTP header |
46
|
|
|
* |
47
|
|
|
* @param string $header |
48
|
|
|
* Header name |
49
|
|
|
* @param string $value |
50
|
|
|
* Header value |
51
|
|
|
* @codeCoverageIgnore |
52
|
|
|
*/ |
53
|
|
|
protected function header(string $header, string $value) |
54
|
|
|
{ |
55
|
|
|
@header($header . ':' . $value); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Method runs logic functions |
60
|
|
|
* |
61
|
|
|
* @param \Mezon\Service\ServiceBaseLogicInterface $serviceLogic |
62
|
|
|
* object with all service logic |
63
|
|
|
* @param string $method |
64
|
|
|
* logic's method to be executed |
65
|
|
|
* @param array $params |
66
|
|
|
* logic's parameters |
67
|
|
|
* @return mixed Result of the called method |
68
|
|
|
*/ |
69
|
|
|
public function callLogic(\Mezon\Service\ServiceBaseLogicInterface $serviceLogic, string $method, array $params = []) |
70
|
|
|
{ |
71
|
|
|
$this->header('Content-Type', 'text/html; charset=utf-8'); |
72
|
|
|
|
73
|
|
|
return parent::callLogic($serviceLogic, $method, $params); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Method runs logic functions |
78
|
|
|
* |
79
|
|
|
* @param \Mezon\Service\ServiceBaseLogicInterface $serviceLogic |
80
|
|
|
* object with all service logic |
81
|
|
|
* @param string $method |
82
|
|
|
* logic's method to be executed |
83
|
|
|
* @param array $params |
84
|
|
|
* logic's parameters |
85
|
|
|
* @return mixed Result of the called method |
86
|
|
|
*/ |
87
|
|
|
public function callPublicLogic( |
88
|
|
|
\Mezon\Service\ServiceBaseLogicInterface $serviceLogic, |
89
|
|
|
string $method, |
90
|
|
|
array $params = []) |
91
|
|
|
{ |
92
|
|
|
$this->header('Content-Type', 'text/html; charset=utf-8'); |
93
|
|
|
|
94
|
|
|
return parent::callPublicLogic($serviceLogic, $method, $params); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Method outputs exception data |
99
|
|
|
* |
100
|
|
|
* @param array $e |
101
|
|
|
* exception data |
102
|
|
|
*/ |
103
|
|
|
public function outputException(array $e): void |
104
|
|
|
{ |
105
|
|
|
$this->header('Content-Type', 'text/html; charset=utf-8'); |
106
|
|
|
|
107
|
|
|
print(json_encode($e)); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.