1 | <?php |
||||||
2 | |||||||
3 | /** |
||||||
4 | * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
||||||
5 | * @copyright Aimeos (aimeos.org), 2015-2021 |
||||||
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 string $path Name of the client separated by slashes, e.g "product/property" |
||||||
36 | */ |
||||||
37 | public function __construct( \Aimeos\Admin\JsonAdm\Iface $client, \Aimeos\MShop\Context\Item\Iface $context, string $path ) |
||||||
38 | { |
||||||
39 | parent::__construct( $context, $path ); |
||||||
40 | |||||||
41 | $this->client = $client; |
||||||
42 | } |
||||||
43 | |||||||
44 | |||||||
45 | /** |
||||||
46 | * Passes unknown methods to wrapped objects |
||||||
47 | * |
||||||
48 | * @param string $name Name of the method |
||||||
49 | * @param array $param List of method parameter |
||||||
50 | * @return mixed Returns the value of the called method |
||||||
51 | * @throws \Aimeos\Admin\JsonAdm\Exception If method call failed |
||||||
52 | */ |
||||||
53 | public function __call( string $name, array $param ) |
||||||
54 | { |
||||||
55 | return @call_user_func_array( array( $this->client, $name ), $param ); |
||||||
56 | } |
||||||
57 | |||||||
58 | |||||||
59 | /** |
||||||
60 | * Deletes the resource or the resource list |
||||||
61 | * |
||||||
62 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||||||
63 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||||||
64 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||||||
65 | */ |
||||||
66 | public function delete( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
||||||
67 | { |
||||||
68 | return $this->client->delete( $request, $response ); |
||||||
69 | } |
||||||
70 | |||||||
71 | |||||||
72 | /** |
||||||
73 | * Returns the requested resource or the resource list |
||||||
74 | * |
||||||
75 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||||||
76 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||||||
77 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||||||
78 | */ |
||||||
79 | public function get( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
||||||
80 | { |
||||||
81 | return $this->client->get( $request, $response ); |
||||||
82 | } |
||||||
83 | |||||||
84 | |||||||
85 | |||||||
86 | /** |
||||||
87 | * Updates the resource or the resource list partitially |
||||||
88 | * |
||||||
89 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||||||
90 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||||||
91 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||||||
92 | */ |
||||||
93 | public function patch( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
||||||
94 | { |
||||||
95 | return $this->client->patch( $request, $response ); |
||||||
96 | } |
||||||
97 | |||||||
98 | |||||||
99 | |||||||
100 | /** |
||||||
101 | * Creates or updates the resource or the resource list |
||||||
102 | * |
||||||
103 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||||||
104 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||||||
105 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||||||
106 | */ |
||||||
107 | public function post( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
||||||
108 | { |
||||||
109 | return $this->client->post( $request, $response ); |
||||||
110 | } |
||||||
111 | |||||||
112 | |||||||
113 | |||||||
114 | /** |
||||||
115 | * Creates or updates the resource or the resource list |
||||||
116 | * |
||||||
117 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||||||
118 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||||||
119 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||||||
120 | */ |
||||||
121 | public function put( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
||||||
122 | { |
||||||
123 | return $this->client->put( $request, $response ); |
||||||
124 | } |
||||||
125 | |||||||
126 | |||||||
127 | |||||||
128 | /** |
||||||
129 | * Returns the available REST verbs |
||||||
130 | * |
||||||
131 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||||||
132 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||||||
133 | * @param string|null $prefix Form parameter prefix when nesting parameters is required |
||||||
134 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||||||
135 | */ |
||||||
136 | public function options( ServerRequestInterface $request, ResponseInterface $response, |
||||||
137 | string $prefix = null ) : \Psr\Http\Message\ResponseInterface |
||||||
138 | { |
||||||
139 | return $this->client->options( $request, $response, $prefix ); |
||||||
140 | } |
||||||
141 | |||||||
142 | |||||||
143 | /** |
||||||
144 | * Returns the Aimeos bootstrap object |
||||||
145 | * |
||||||
146 | * @return \Aimeos\Bootstrap The Aimeos bootstrap object |
||||||
147 | */ |
||||||
148 | public function getAimeos() : \Aimeos\Bootstrap |
||||||
149 | { |
||||||
150 | return $this->client->getAimeos(); |
||||||
151 | } |
||||||
152 | |||||||
153 | |||||||
154 | /** |
||||||
155 | * Sets the Aimeos bootstrap object |
||||||
156 | * |
||||||
157 | * @param \Aimeos\Bootstrap $aimeos The Aimeos bootstrap object |
||||||
158 | * @return \Aimeos\Admin\JsonAdm\Iface Reference to this object for fluent calls |
||||||
159 | */ |
||||||
160 | public function setAimeos( \Aimeos\Bootstrap $aimeos ) : \Aimeos\Admin\JsonAdm\Iface |
||||||
161 | { |
||||||
162 | parent::setAimeos( $aimeos ); |
||||||
163 | |||||||
164 | $this->client->setAimeos( $aimeos ); |
||||||
165 | return $this; |
||||||
166 | } |
||||||
167 | |||||||
168 | |||||||
169 | /** |
||||||
170 | * Returns the view object that will generate the admin output. |
||||||
171 | * |
||||||
172 | * @return \Aimeos\MW\View\Iface The view object which generates the admin output |
||||||
173 | */ |
||||||
174 | public function view() : \Aimeos\MW\View\Iface |
||||||
175 | { |
||||||
176 | return $this->client->view(); |
||||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
177 | } |
||||||
178 | |||||||
179 | |||||||
180 | /** |
||||||
181 | * Sets the view object that will generate the admin output. |
||||||
182 | * |
||||||
183 | * @param \Aimeos\MW\View\Iface $view The view object which generates the admin output |
||||||
184 | * @return \Aimeos\Admin\JsonAdm\Iface Reference to this object for fluent calls |
||||||
185 | */ |
||||||
186 | public function setView( \Aimeos\MW\View\Iface $view ) : \Aimeos\Admin\JsonAdm\Iface |
||||||
187 | { |
||||||
188 | parent::setView( $view ); |
||||||
189 | |||||||
190 | $this->client->setView( $view ); |
||||||
0 ignored issues
–
show
The method
setView() does not exist on Aimeos\Admin\JsonAdm\Iface . It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Admin\JsonAdm\Common\Iface or Aimeos\Admin\JsonAdm\Common\Decorator\Iface . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
191 | return $this; |
||||||
192 | } |
||||||
193 | |||||||
194 | |||||||
195 | /** |
||||||
196 | * Returns the underlying admin client object; |
||||||
197 | * |
||||||
198 | * @return \Aimeos\Admin\JsonAdm\Iface Admin client object |
||||||
199 | */ |
||||||
200 | protected function getClient() : \Aimeos\Admin\JsonAdm\Iface |
||||||
201 | { |
||||||
202 | return $this->client; |
||||||
203 | } |
||||||
204 | } |
||||||
205 |