1 | <?php |
||
13 | class JsonRpcRequest extends HttpRequest |
||
14 | { |
||
15 | /** |
||
16 | * Holds the JSON-RPC request payload. |
||
17 | * |
||
18 | * @var Object |
||
19 | */ |
||
20 | private $payload; |
||
21 | |||
22 | /** |
||
23 | * Constructor for a request. |
||
24 | * |
||
25 | * @param string $controller The controller being requested. |
||
26 | * @param object $payload The action being invoked. |
||
27 | * @param string $verb (optional) The HTTP verb (usually POST). |
||
28 | */ |
||
29 | 6 | public function __construct($controller, $payload, $verb = 'POST') |
|
39 | |||
40 | /** |
||
41 | * Returns the POST data parameter associated with the specified key. |
||
42 | * |
||
43 | * Since JSON-RPC and POST'ed data are mutually exclusive this returns null, or the default if provided. |
||
44 | * |
||
45 | * @param string $param The POST data parameter to retrieve. |
||
46 | * @param mixed $defaultValue The default value to use when the key is not present. |
||
47 | * @param mixed $filters The array of filters (or single filter) to apply to the data. Ignored. |
||
48 | * @return mixed Returns null because POST is not possible, or the default value if the parameter is not present. |
||
49 | */ |
||
50 | 1 | public function getPost($param, $defaultValue = null, $filters = array()) |
|
54 | |||
55 | /** |
||
56 | * Get the request version. |
||
57 | * |
||
58 | * @return string The request's version string. "1.0" is assumed if version is not present in the request. |
||
59 | */ |
||
60 | 4 | public function getVersion() |
|
64 | |||
65 | /** |
||
66 | * Get the request method. |
||
67 | * |
||
68 | * @return string The request method name. |
||
69 | */ |
||
70 | 1 | public function getMethod() |
|
74 | |||
75 | /** |
||
76 | * Get the request identifier |
||
77 | * |
||
78 | * @return mixed The request identifier. This is generally a string, but the JSON-RPC spec isn't strict. |
||
79 | */ |
||
80 | 4 | public function getIdentifier() |
|
84 | |||
85 | /** |
||
86 | * Get request parameters. |
||
87 | * |
||
88 | * Note: Since PHP does not support named params, named params are turned into a single request object parameter. |
||
89 | * |
||
90 | * @return array An array of request paramters |
||
91 | */ |
||
92 | 3 | public function getParameters() |
|
100 | |||
101 | /** |
||
102 | * Returns whether this request is minimally valid for JSON RPC. |
||
103 | * @return Returns true if the payload is valid and false otherwise. |
||
104 | */ |
||
105 | 3 | public function isValid() |
|
110 | } |
||
111 |