1 | <?php |
||
12 | class LaravelLocator implements LocatorInterface |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * The handlers |
||
17 | * @var |
||
18 | */ |
||
19 | protected $handlers; |
||
20 | |||
21 | /** |
||
22 | * Bind a handler instance to receive all commands with a certain class |
||
23 | * |
||
24 | * @param string $handler Handler to receive class name |
||
25 | * @param string $commandClassName Command class e.g. "My\TaskAddedCommand" |
||
26 | */ |
||
27 | 1 | public function addHandler($handler, $commandClassName) |
|
28 | { |
||
29 | 1 | $handlerInstance = app($handler); |
|
30 | $this->handlers[$commandClassName] = $handlerInstance; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Allows you to add multiple handlers at once. |
||
35 | * |
||
36 | * The map should be an array in the format of: |
||
37 | * [ |
||
38 | * AddTaskCommand::class => $someHandlerClassName, |
||
39 | * CompleteTaskCommand::class => $someHandlerClassName, |
||
40 | * ] |
||
41 | * |
||
42 | * @param array $commandClassToHandlerMap |
||
43 | */ |
||
44 | 2 | public function addHandlers(array $commandClassToHandlerMap) |
|
50 | |||
51 | /** |
||
52 | * Retrieves the handler for a specified command |
||
53 | * |
||
54 | * @param string $commandName |
||
55 | * |
||
56 | * @return object |
||
57 | * |
||
58 | * @throws MissingHandlerException |
||
59 | */ |
||
60 | public function getHandlerForCommand($commandName) |
||
68 | } |
||
69 |