1 | <?php |
||
23 | class Standard extends Base implements \Aimeos\Client\JsonApi\Iface |
||
24 | { |
||
25 | private $controller; |
||
26 | |||
27 | |||
28 | /** |
||
29 | * Initializes the client |
||
30 | * |
||
31 | * @param \Aimeos\MShop\Context\Item\Iface $context MShop context object |
||
32 | * @param \Aimeos\MW\View\Iface $view View object |
||
33 | * @param array $templatePaths List of file system paths where the templates are stored |
||
34 | * @param string $path Name of the client, e.g "basket" |
||
35 | */ |
||
36 | public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
||
37 | { |
||
38 | parent::__construct( $context, $view, $templatePaths, $path ); |
||
39 | |||
40 | $this->controller = \Aimeos\Controller\Frontend\Basket\Factory::createController( $this->getContext() ); |
||
41 | } |
||
42 | |||
43 | |||
44 | /** |
||
45 | * Deletes the resource or the resource list |
||
46 | * |
||
47 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||
48 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||
49 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||
50 | */ |
||
51 | public function delete( ServerRequestInterface $request, ResponseInterface $response ) |
||
52 | { |
||
53 | $view = $this->getView(); |
||
54 | |||
55 | try |
||
56 | { |
||
57 | $this->clearCache(); |
||
58 | |||
59 | $status = 200; |
||
60 | $type = $view->param( 'id', 'default' ); |
||
61 | $view->item = $this->controller->setType( $type )->clear()->get(); |
||
62 | } |
||
63 | catch( \Aimeos\MShop\Exception $e ) |
||
64 | { |
||
65 | $status = 404; |
||
66 | $view->errors = $this->getErrorDetails( $e, 'mshop' ); |
||
67 | } |
||
68 | catch( \Exception $e ) |
||
69 | { |
||
70 | $status = 500; |
||
71 | $view->errors = $this->getErrorDetails( $e ); |
||
72 | } |
||
73 | |||
74 | return $this->render( $response, $view, $status ); |
||
75 | } |
||
76 | |||
77 | |||
78 | /** |
||
79 | * Returns the resource or the resource list |
||
80 | * |
||
81 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||
82 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||
83 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||
84 | */ |
||
85 | public function get( ServerRequestInterface $request, ResponseInterface $response ) |
||
118 | |||
119 | |||
120 | /** |
||
121 | * Updates the resource or the resource list partitially |
||
122 | * |
||
123 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||
124 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||
125 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||
126 | */ |
||
127 | public function patch( ServerRequestInterface $request, ResponseInterface $response ) |
||
163 | |||
164 | |||
165 | /** |
||
166 | * Creates or updates the resource or the resource list |
||
167 | * |
||
168 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||
169 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||
170 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||
171 | */ |
||
172 | public function post( ServerRequestInterface $request, ResponseInterface $response ) |
||
199 | |||
200 | |||
201 | /** |
||
202 | * Returns the available REST verbs and the available parameters |
||
203 | * |
||
204 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
||
205 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||
206 | * @param string|null $prefix Form parameter prefix when nesting parameters is required |
||
207 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||
208 | */ |
||
209 | public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
||
230 | |||
231 | |||
232 | /** |
||
233 | * Returns the integer constant for the basket parts that should be included |
||
234 | * |
||
235 | * @param \Aimeos\MW\View\Iface $view View instance |
||
236 | * @return integer Constant from Aimeos\MShop\Order\Manager\Base\Base |
||
237 | */ |
||
238 | protected function getParts( \Aimeos\MW\View\Iface $view ) |
||
259 | |||
260 | |||
261 | /** |
||
262 | * Returns the response object with the rendered header and body |
||
263 | * |
||
264 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
||
265 | * @param \Aimeos\MW\View\Iface $view View instance |
||
266 | * @param integer $status HTTP status code |
||
267 | * @param boolean $allow True to allow all HTTP methods, false for GET only |
||
268 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
||
269 | */ |
||
270 | protected function render( ResponseInterface $response, \Aimeos\MW\View\Iface $view, $status, $allow = true ) |
||
308 | } |
||
309 |