1 | <?php |
||
20 | class Bus implements BusInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var GateInterface |
||
24 | */ |
||
25 | protected $gate; |
||
26 | |||
27 | /** |
||
28 | * @var mixed |
||
29 | */ |
||
30 | protected $handler; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $messages = array(); |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $method = 'handle'; |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function getName() |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function setMethod($method) |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function getGate() |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function setGate(GateInterface $gate) |
||
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | public function setHandler($handler) |
||
81 | |||
82 | /** |
||
83 | * Register messages. |
||
84 | * |
||
85 | * @param array $messages |
||
86 | */ |
||
87 | public function registers(array $messages) |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function register($message, $handler) |
||
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | public function isRegistered(MessageInterface $message) |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function dispatch(MessageInterface $message) |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | public function dispatchNow(MessageInterface $message) |
||
130 | |||
131 | /** |
||
132 | * Invoke message. |
||
133 | * |
||
134 | * @param MessageInterface $message |
||
135 | * @param mixed $handler |
||
136 | * @param string $class |
||
137 | * |
||
138 | * @return mixed |
||
139 | */ |
||
140 | protected function invoke(MessageInterface $message, $handler, $class) |
||
151 | |||
152 | /** |
||
153 | * Default dispatcher for message. |
||
154 | * |
||
155 | * @param MessageInterface $message |
||
156 | * @param mixed $handler |
||
157 | * |
||
158 | * @return mixed |
||
159 | */ |
||
160 | protected function handle(MessageInterface $message, $handler) |
||
168 | |||
169 | /** |
||
170 | * Assert valid handler. |
||
171 | * |
||
172 | * @param string $class |
||
173 | * @param mixed $handler |
||
174 | */ |
||
175 | protected function assertValidHandler($class, $handler) |
||
187 | |||
188 | /** |
||
189 | * Assert valid object handler. |
||
190 | * |
||
191 | * @param mixed $handler |
||
192 | */ |
||
193 | protected function assertValidObjectHandler($handler) |
||
199 | |||
200 | /** |
||
201 | * Build class from string. |
||
202 | * |
||
203 | * @param string $class |
||
204 | * |
||
205 | * @return mixed|null |
||
206 | */ |
||
207 | protected function buildClassString($class) |
||
215 | |||
216 | /** |
||
217 | * Build handler. |
||
218 | * |
||
219 | * @param mixed $handler |
||
220 | * |
||
221 | * @return mixed|null |
||
222 | */ |
||
223 | protected function buildHandler($handler) |
||
238 | } |
||
239 |