1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Saxulum\SaxulumControllerProvider\Map; |
4
|
|
|
|
5
|
|
|
class Method |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var Controller |
9
|
|
|
*/ |
10
|
|
|
protected $controller; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
protected $name; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var array |
19
|
|
|
*/ |
20
|
|
|
protected $injectionKeys = array(); |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param array $methodInjectionInfo |
24
|
|
|
*/ |
25
|
|
|
public function __construct(array $methodInjectionInfo = null) |
26
|
|
|
{ |
27
|
|
|
if (!is_null($methodInjectionInfo)) { |
28
|
|
|
$this->setName($methodInjectionInfo['name']); |
29
|
|
|
$this->setInjectionKeys($methodInjectionInfo['injectionKeys']); |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param Controller $controller |
35
|
|
|
* @param bool $stopPropagation |
36
|
|
|
* @return $this |
37
|
|
|
*/ |
38
|
|
|
public function setController(Controller $controller, $stopPropagation = false) |
39
|
|
|
{ |
40
|
|
|
if (!$stopPropagation) { |
41
|
|
|
$controller->addMethod($this, true); |
42
|
|
|
} |
43
|
|
|
$this->controller = $controller; |
44
|
|
|
|
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return Controller |
50
|
|
|
*/ |
51
|
|
|
public function end() |
52
|
|
|
{ |
53
|
|
|
return $this->controller; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $name |
58
|
|
|
* @return $this |
59
|
|
|
*/ |
60
|
|
|
public function setName($name) |
61
|
|
|
{ |
62
|
|
|
$this->name = $name; |
63
|
|
|
|
64
|
|
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
public function getName() |
71
|
|
|
{ |
72
|
|
|
return $this->name; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param array $injectionKeys |
77
|
|
|
* @return $this |
78
|
|
|
*/ |
79
|
|
|
public function setInjectionKeys($injectionKeys) |
80
|
|
|
{ |
81
|
|
|
$this->injectionKeys = $injectionKeys; |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return array |
88
|
|
|
*/ |
89
|
|
|
public function getInjectionKeys() |
90
|
|
|
{ |
91
|
|
|
return $this->injectionKeys; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return bool |
96
|
|
|
*/ |
97
|
|
|
public function hasInjectionKeys() |
98
|
|
|
{ |
99
|
|
|
return $this->injectionKeys ? true : false; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return array |
104
|
|
|
*/ |
105
|
|
|
public function __toArray() |
106
|
|
|
{ |
107
|
|
|
$methodInjectionInfo = array(); |
108
|
|
|
$methodInjectionInfo['name'] = $this->getName(); |
109
|
|
|
$methodInjectionInfo['injectionKeys'] = $this->getInjectionKeys(); |
110
|
|
|
|
111
|
|
|
return $methodInjectionInfo; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|