Skip to content

Commit 0d086a7

Browse files
committed
Merge branch 'develop'
2 parents e993082 + 9cbd011 commit 0d086a7

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

binshopsrest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ public function hookactionDispatcherBefore($controller)
255255
'message' => 'This endpoint is not defined.',
256256
'code' => 410
257257
]);
258+
die;
258259
}
259260

260261
$controller = Controller::getController($controller_class);
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
abstract class Controller extends ControllerCore
4+
{
5+
public function restRun(){
6+
header('Content-Type: ' . "application/json");
7+
if (Tools::getValue('iso_currency')){
8+
$_GET['id_currency'] = (string)Currency::getIdByIsoCode(Tools::getValue('currency'));
9+
$_GET['SubmitCurrency'] = "1";
10+
}
11+
12+
parent::init();
13+
14+
$response = [
15+
'success' => true,
16+
'code' => 210,
17+
'psdata' => null,
18+
'message' => 'empty'
19+
];
20+
21+
switch ($_SERVER['REQUEST_METHOD']) {
22+
case 'GET':
23+
$response = $this->processGetRequest();
24+
break;
25+
case 'POST':
26+
$response = $this->processPostRequest();
27+
break;
28+
case 'PATCH':
29+
case 'PUT':
30+
$response = $this->processPutRequest();
31+
break;
32+
case 'DELETE':
33+
$response = $this->processDeleteRequest();
34+
break;
35+
default:
36+
// throw some error or whatever
37+
}
38+
39+
$this->ajaxRender(json_encode($response));
40+
die;
41+
}
42+
43+
protected function processGetRequest(){
44+
return [
45+
'success' => true,
46+
'code' => 310,
47+
'psdata' => null,
48+
'message' => $this->trans('GET not supported on this path', [], 'Modules.Binshopsrest.Admin'),
49+
];
50+
}
51+
52+
protected function processPostRequest(){
53+
return [
54+
'success' => true,
55+
'code' => 310,
56+
'psdata' => null,
57+
'message' => $this->trans('POST not supported on this path', [], 'Modules.Binshopsrest.Admin'),
58+
];
59+
}
60+
61+
protected function processPutRequest(){
62+
return [
63+
'success' => true,
64+
'code' => 310,
65+
'psdata' => null,
66+
'message' => $this->trans('PUT not supported on this path', [], 'Modules.Binshopsrest.Admin'),
67+
];
68+
}
69+
70+
protected function processDeleteRequest(){
71+
return [
72+
'success' => true,
73+
'code' => 310,
74+
'psdata' => null,
75+
'message' => $this->trans('DELETE not supported on this path', [], 'Modules.Binshopsrest.Admin'),
76+
];
77+
}
78+
}

0 commit comments

Comments
 (0)