1 | <?php |
||
19 | class Bus implements CommandBusInterface |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * @var CommandBus |
||
24 | */ |
||
25 | protected $bus; |
||
26 | /** |
||
27 | * @var CommandNameExtractor |
||
28 | */ |
||
29 | protected $CommandNameExtractor; |
||
30 | /** |
||
31 | * @var MethodNameInflector |
||
32 | */ |
||
33 | protected $MethodNameInflector; |
||
34 | /** |
||
35 | * @var LocatorInterface |
||
36 | */ |
||
37 | protected $HandlerLocator; |
||
38 | |||
39 | |||
40 | /** |
||
41 | * @param MethodNameInflector $MethodNameInflector |
||
42 | * @param CommandNameExtractor $CommandNameExtractor |
||
43 | * @param LocatorInterface $HandlerLocator |
||
44 | */ |
||
45 | 7 | public function __construct( |
|
54 | |||
55 | /** |
||
56 | * Dispatch a command |
||
57 | * |
||
58 | * @param object $command Command to be dispatched |
||
59 | * @param array $input Array of input to map to the command |
||
60 | * @param array $middleware Array of middleware class name to add to the stack, they are resolved from the laravel container |
||
61 | * @return mixed |
||
62 | */ |
||
63 | 7 | public function dispatch($command, array $input = [], array $middleware = []) |
|
67 | |||
68 | /** |
||
69 | * Add the Command Handler |
||
70 | * |
||
71 | * @param string $command Class name of the command |
||
72 | * @param string $handler Class name of the handler to be resolved from the Laravel Container |
||
73 | * @return mixed |
||
74 | */ |
||
75 | 7 | public function addHandler($command, $handler) |
|
79 | |||
80 | /** |
||
81 | * Handle the command |
||
82 | * |
||
83 | * @param $command |
||
84 | * @param $input |
||
85 | * @param $middleware |
||
86 | * @return mixed |
||
87 | */ |
||
88 | 7 | protected function handleTheCommand($command, $input, array $middleware) |
|
99 | |||
100 | /** |
||
101 | * Resolve the middleware stack from the laravel container |
||
102 | * |
||
103 | * @param $middleware |
||
104 | * @return array |
||
105 | */ |
||
106 | 7 | protected function resolveMiddleware(array $middleware) |
|
115 | |||
116 | /** |
||
117 | * Map the input to the command |
||
118 | * |
||
119 | * @param $command |
||
120 | * @param $input |
||
121 | * @return object |
||
122 | */ |
||
123 | 7 | protected function mapInputToCommand($command, $input) |
|
149 | |||
150 | /** |
||
151 | * Returns Default Value for parameter if it exists Or Fail |
||
152 | * |
||
153 | * @ReflectionParameter $parameter |
||
154 | * @return mixed |
||
155 | */ |
||
156 | 5 | private function getDefaultValueOrFail($parameter) |
|
164 | |||
165 | } |
||
166 |