1 | <?php |
||
21 | class TransactionableBus implements CommandBusInterface |
||
22 | { |
||
23 | |||
24 | /** @var CommandBus */ |
||
25 | protected $bus; |
||
26 | |||
27 | /** @var CommandNameExtractor */ |
||
28 | protected $commandNameExtractor; |
||
29 | |||
30 | /** @var MethodNameInflector */ |
||
31 | protected $methodNameInflector; |
||
32 | |||
33 | /** @var LocatorInterface */ |
||
34 | protected $handlerLocator; |
||
35 | |||
36 | public function __construct( |
||
45 | |||
46 | /** |
||
47 | * Dispatch a command |
||
48 | * |
||
49 | * @param object $command Command to be dispatched |
||
50 | * @param array $input Array of input to map to the command |
||
51 | * @param array $middleware Array of middleware class name to add to the stack, they are resolved from the laravel container |
||
52 | * @throws CommandHandlerNotExists |
||
53 | * @return mixed |
||
54 | */ |
||
55 | public function dispatch($command, array $input = [], array $middleware = []) |
||
61 | |||
62 | private function bindCommandWitHisCommandHandler($command) |
||
72 | |||
73 | /** |
||
74 | * @param $command |
||
75 | * @return string |
||
76 | */ |
||
77 | private function getNameOfClass($command): string |
||
87 | |||
88 | /** |
||
89 | * Add the Command Handler |
||
90 | * |
||
91 | * @param string $command Class name of the command |
||
92 | * @param string $handler Class name of the handler to be resolved from the Laravel Container |
||
93 | * @return mixed |
||
94 | */ |
||
95 | public function addHandler($command, $handler) |
||
99 | |||
100 | /** |
||
101 | * Handle the command |
||
102 | * |
||
103 | * @param $command |
||
104 | * @param $input |
||
105 | * @param $middleware |
||
106 | * @return mixed |
||
107 | */ |
||
108 | protected function handleTheCommand($command, $input, array $middleware) |
||
120 | |||
121 | /** |
||
122 | * Resolve the middleware stack from the laravel container |
||
123 | * |
||
124 | * @param $middleware |
||
125 | * @return array |
||
126 | */ |
||
127 | protected function resolveMiddleware(array $middleware) |
||
136 | |||
137 | /** |
||
138 | * Map the input to the command |
||
139 | * |
||
140 | * @param $command |
||
141 | * @param $input |
||
142 | * @return object |
||
143 | */ |
||
144 | protected function mapInputToCommand($command, $input) |
||
170 | |||
171 | /** |
||
172 | * Returns Default Value for parameter if it exists Or Fail |
||
173 | * |
||
174 | * @ReflectionParameter $parameter |
||
175 | * @return mixed |
||
176 | */ |
||
177 | private function getDefaultValueOrFail($parameter) |
||
185 | |||
186 | } |
||
187 |