-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevcenter.admin.controller.php
68 lines (54 loc) · 2.32 KB
/
devcenter.admin.controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
use GuzzleHttp\Psr7\ServerRequest;
use Monoless\Xe\OAuth2\Server\Utils\ResponseUtil;
use Zend\Diactoros\Response\JsonResponse;
class devcenterAdminController extends devcenter
{
const MODULE_NAME = 'devcenter';
public function procDevcenterAdminConfig()
{
$request = ServerRequest::fromGlobals();
/**
* @var \devcenterModel $model
*/
$model = getModel(self::MODULE_NAME);
$config = $model->getConfig();
$params = $request->getParsedBody();
if (array_key_exists('use_rate_limiter', $params)) $config->use_rate_limiter = (1 == $params['use_rate_limiter']);
if (array_key_exists('use_app_thumbnail', $params)) $config->use_app_thumbnail = (1 == $params['use_app_thumbnail']);
if (array_key_exists('use_app_stop_insert', $params)) $config->use_app_stop_insert = (1 == $params['use_app_stop_insert']);
if (array_key_exists('rate_limit_capacity', $params)) $config->rate_limit_capacity = $params['rate_limit_capacity'];
if (array_key_exists('redis_host', $params)) $config->redis_host = $params['redis_host'];
if (array_key_exists('redis_port', $params)) $config->redis_port = $params['redis_port'];
$model->saveConfig($config);
$this->setRedirectUrl(Context::get('error_return_url'));
}
public function procDevcenterAdminRemoveApp()
{
$request = ServerRequest::fromGlobals();
/**
* @var \devcenterModel $devcenterModel
*/
$devcenterModel = getModel(self::MODULE_NAME);
$params = $request->getParsedBody();
$uniqueAppSrl = array_key_exists('unique_app_srl', $params) ? $params['unique_app_srl'] : null;
$entry = $devcenterModel->getAppByClientId($uniqueAppSrl);
if (!$entry) {
ResponseUtil::finalizeResponse(new JsonResponse([
'status' => false,
'error' => 'app_not_exist',
], 404));
}
$status = $devcenterModel->deleteApp($entry);
if (!$status) {
ResponseUtil::finalizeResponse(new JsonResponse([
'status' => false,
'error' => 'invalid_request',
], 500));
}
ResponseUtil::finalizeResponse(new JsonResponse([
'status' => true,
'error' => ''
]));
}
}