1 | <?php |
||
18 | class Bus implements CommandBusInterface |
||
19 | { |
||
20 | |||
21 | /** @var CommandBus */ |
||
22 | protected $bus; |
||
23 | |||
24 | /** @var CommandNameExtractor */ |
||
25 | protected $commandNameExtractor; |
||
26 | |||
27 | /** @var MethodNameInflector */ |
||
28 | protected $methodNameInflector; |
||
29 | |||
30 | /** @var LocatorInterface */ |
||
31 | protected $handlerLocator; |
||
32 | |||
33 | 4 | public function __construct( |
|
42 | |||
43 | /** |
||
44 | * Dispatch a command |
||
45 | * |
||
46 | * @param object $command Command to be dispatched |
||
47 | * @param array $middleware Array of middleware class name to add to the stack, they are resolved from the laravel container |
||
48 | * @throws CommandHandlerNotExists |
||
49 | * @return mixed |
||
50 | */ |
||
51 | 4 | public function dispatch($command, array $middleware = []) |
|
57 | |||
58 | 4 | private function bindCommandWitHisCommandHandler($command) |
|
68 | |||
69 | /** |
||
70 | * @param $command |
||
71 | * @return string |
||
72 | */ |
||
73 | 4 | private function getNameOfClass($command): string |
|
83 | |||
84 | /** |
||
85 | * Add the Command Handler |
||
86 | * |
||
87 | * @param string $command Class name of the command |
||
88 | * @param string $handler Class name of the handler to be resolved from the Laravel Container |
||
89 | * @return mixed |
||
90 | */ |
||
91 | 3 | public function addHandler($command, $handler) |
|
95 | |||
96 | /** |
||
97 | * Handle the command |
||
98 | * |
||
99 | * @param $command |
||
100 | * @param $middleware |
||
101 | * @return mixed |
||
102 | */ |
||
103 | 3 | protected function handleTheCommand($command, array $middleware) |
|
114 | |||
115 | /** |
||
116 | * Resolve the middleware stack from the laravel container |
||
117 | * |
||
118 | * @param $middleware |
||
119 | * @return array |
||
120 | */ |
||
121 | 3 | protected function resolveMiddleware(array $middleware) |
|
130 | |||
131 | } |
||
132 |