-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathController.php
57 lines (48 loc) · 1.28 KB
/
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
<?php
namespace georgique\yii2\jsonrpc;
use yii\filters\ContentNegotiator;
use yii\web\Response;
use Yii;
/**
* Class Controller
* @package georgique\yii2\jsonrpc
*/
class Controller extends \yii\web\Controller
{
// Pass params as function arguments
const JSON_RPC_PARAMS_PASS_FUNCARGS = 1;
// Pass params as request body
const JSON_RPC_PARAMS_PASS_BODY = 2;
/**
* @var int $paramsPassMethod Defines method to pass params to the target action.
*/
public $paramsPassMethod = self::JSON_RPC_PARAMS_PASS_FUNCARGS;
/**
* @var array Whether JSON parse should parse objects in `params` as associative arrays or objects
*/
public $requestParseAsArray = true;
public function actions()
{
return [
'index' => [
'class' => Action::class,
'paramsPassMethod' => $this->paramsPassMethod,
'requestParseAsArray' => $this->requestParseAsArray
]
];
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'contentNegotiator' => [
'class' => ContentNegotiator::class,
'formats' => [
'*' => Response::FORMAT_JSON,
],
]
];
}
}