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 | 4 | private function getNameOfClass($command): string |
|
75 | |||
76 | /** |
||
77 | * Add the Command Handler |
||
78 | * |
||
79 | * @param string $command Class name of the command |
||
80 | * @param string $handler Class name of the handler to be resolved from the Laravel Container |
||
81 | * @return mixed |
||
82 | */ |
||
83 | 3 | public function addHandler($command, $handler) |
|
87 | |||
88 | /** |
||
89 | * Handle the command |
||
90 | * |
||
91 | * @param $command |
||
92 | * @param $middleware |
||
93 | * @return mixed |
||
94 | */ |
||
95 | 3 | protected function handleTheCommand($command, array $middleware) |
|
106 | |||
107 | /** |
||
108 | * Resolve the middleware stack from the laravel container |
||
109 | * |
||
110 | * @param $middleware |
||
111 | * @return array |
||
112 | */ |
||
113 | 3 | protected function resolveMiddleware(array $middleware) |
|
122 | |||
123 | } |
||
124 |