1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2016 |
6
|
|
|
* @package Admin |
7
|
|
|
* @subpackage JsonAdm |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Admin\JsonAdm\Common\Decorator; |
12
|
|
|
|
13
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
14
|
|
|
use Psr\Http\Message\ResponseInterface; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Provides common methods for JSON API client decorators |
19
|
|
|
* |
20
|
|
|
* @package Admin |
21
|
|
|
* @subpackage JsonAdm |
22
|
|
|
*/ |
23
|
|
|
abstract class Base |
24
|
|
|
extends \Aimeos\Admin\JsonAdm\Base |
|
|
|
|
25
|
|
|
implements \Aimeos\Admin\JsonAdm\Common\Decorator\Iface |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
private $client; |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Initializes the client decorator. |
32
|
|
|
* |
33
|
|
|
* @param \Aimeos\Admin\JsonAdm\Iface $client Client object |
34
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
35
|
|
|
* @param \Aimeos\MW\View\Iface $view View object |
36
|
|
|
* @param array $templatePaths List of file system paths where the templates are stored |
37
|
|
|
* @param string $path Name of the client separated by slashes, e.g "product/property" |
38
|
|
|
*/ |
39
|
|
|
public function __construct( \Aimeos\Admin\JsonAdm\Iface $client, |
40
|
|
|
\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
41
|
|
|
{ |
42
|
|
|
parent::__construct( $context, $view, $templatePaths, $path ); |
43
|
|
|
|
44
|
|
|
$this->client = $client; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Passes unknown methods to wrapped objects |
50
|
|
|
* |
51
|
|
|
* @param string $name Name of the method |
52
|
|
|
* @param array $param List of method parameter |
53
|
|
|
* @return mixed Returns the value of the called method |
54
|
|
|
* @throws \Aimeos\Admin\JsonAdm\Exception If method call failed |
55
|
|
|
*/ |
56
|
|
|
public function __call( $name, array $param ) |
57
|
|
|
{ |
58
|
|
|
return @call_user_func_array( array( $this->client, $name ), $param ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Deletes the resource or the resource list |
64
|
|
|
* |
65
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request Request object |
66
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response Response object |
67
|
|
|
* @return \Psr\Http\Message\ResponseInterface Modified response object |
68
|
|
|
*/ |
69
|
|
|
public function delete( ServerRequestInterface $request, ResponseInterface $response ) |
70
|
|
|
{ |
71
|
|
|
return $this->client->delete( $request, $response ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Returns the requested resource or the resource list |
77
|
|
|
* |
78
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request Request object |
79
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response Response object |
80
|
|
|
* @return \Psr\Http\Message\ResponseInterface Modified response object |
81
|
|
|
*/ |
82
|
|
|
public function get( ServerRequestInterface $request, ResponseInterface $response ) |
83
|
|
|
{ |
84
|
|
|
return $this->client->get( $request, $response ); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Updates the resource or the resource list partitially |
91
|
|
|
* |
92
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request Request object |
93
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response Response object |
94
|
|
|
* @return \Psr\Http\Message\ResponseInterface Modified response object |
95
|
|
|
*/ |
96
|
|
|
public function patch( ServerRequestInterface $request, ResponseInterface $response ) |
97
|
|
|
{ |
98
|
|
|
return $this->client->patch( $request, $response ); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Creates or updates the resource or the resource list |
105
|
|
|
* |
106
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request Request object |
107
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response Response object |
108
|
|
|
* @return \Psr\Http\Message\ResponseInterface Modified response object |
109
|
|
|
*/ |
110
|
|
|
public function post( ServerRequestInterface $request, ResponseInterface $response ) |
111
|
|
|
{ |
112
|
|
|
return $this->client->post( $request, $response ); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Creates or updates the resource or the resource list |
119
|
|
|
* |
120
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request Request object |
121
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response Response object |
122
|
|
|
* @return \Psr\Http\Message\ResponseInterface Modified response object |
123
|
|
|
*/ |
124
|
|
|
public function put( ServerRequestInterface $request, ResponseInterface $response ) |
125
|
|
|
{ |
126
|
|
|
return $this->client->put( $request, $response ); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Returns the available REST verbs |
133
|
|
|
* |
134
|
|
|
* @param \Psr\Http\Message\ServerRequestInterface $request Request object |
135
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response Response object |
136
|
|
|
* @param string|null $prefix Form parameter prefix when nesting parameters is required |
137
|
|
|
* @return \Psr\Http\Message\ResponseInterface Modified response object |
138
|
|
|
*/ |
139
|
|
|
public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
140
|
|
|
{ |
141
|
|
|
return $this->client->options( $request, $response, $prefix ); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Returns the underlying admin client object; |
147
|
|
|
* |
148
|
|
|
* @return \Aimeos\Admin\JsonAdm\Iface Admin client object |
149
|
|
|
*/ |
150
|
|
|
protected function getClient() |
151
|
|
|
{ |
152
|
|
|
return $this->client; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|