|
1
|
|
|
<?php |
|
2
|
|
|
namespace Yoanm\JsonRpcServer\Domain\Event\Action; |
|
3
|
|
|
|
|
4
|
|
|
use Yoanm\JsonRpcServer\Domain\Event\JsonRpcServerEvent; |
|
5
|
|
|
use Yoanm\JsonRpcServer\Domain\JsonRpcMethodInterface; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class ValidateParamsEvent |
|
9
|
|
|
* |
|
10
|
|
|
* Dispatched before JSON-RPC will be called, in order to validate params |
|
11
|
|
|
*/ |
|
12
|
|
|
class ValidateParamsEvent implements JsonRpcServerEvent |
|
13
|
|
|
{ |
|
14
|
|
|
const EVENT_NAME = 'json_rpc_server_skd.validate_params'; |
|
15
|
|
|
|
|
16
|
|
|
/** @var JsonRpcMethodInterface */ |
|
17
|
|
|
private $method; |
|
18
|
|
|
/** @var array */ |
|
19
|
|
|
private $paramList = []; |
|
20
|
|
|
/** @var mixed[] */ |
|
21
|
|
|
private $violationList = []; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param JsonRpcMethodInterface $method |
|
25
|
|
|
* @param array $paramList |
|
26
|
|
|
*/ |
|
27
|
3 |
|
public function __construct(JsonRpcMethodInterface $method, array $paramList) |
|
28
|
|
|
{ |
|
29
|
3 |
|
$this->method = $method; |
|
30
|
3 |
|
$this->paramList = $paramList; |
|
31
|
3 |
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @return JsonRpcMethodInterface |
|
35
|
|
|
*/ |
|
36
|
1 |
|
public function getMethod() : JsonRpcMethodInterface |
|
37
|
|
|
{ |
|
38
|
1 |
|
return $this->method; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return array |
|
43
|
|
|
*/ |
|
44
|
1 |
|
public function getParamList() : array |
|
45
|
|
|
{ |
|
46
|
1 |
|
return $this->paramList; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param array $violationList |
|
51
|
|
|
* |
|
52
|
|
|
* @return ValidateParamsEvent |
|
53
|
|
|
*/ |
|
54
|
1 |
|
public function setViolationList(array $violationList) : ValidateParamsEvent |
|
55
|
|
|
{ |
|
56
|
1 |
|
$this->violationList = $violationList; |
|
57
|
|
|
|
|
58
|
1 |
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param mixed $violation |
|
63
|
|
|
* |
|
64
|
|
|
* @return ValidateParamsEvent |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function addViolation($violation) : ValidateParamsEvent |
|
67
|
|
|
{ |
|
68
|
1 |
|
$this->violationList[] = $violation; |
|
69
|
|
|
|
|
70
|
1 |
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return array |
|
75
|
|
|
*/ |
|
76
|
2 |
|
public function getViolationList() : array |
|
77
|
|
|
{ |
|
78
|
2 |
|
return $this->violationList; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|