1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace InFw\TacticianAdapter; |
4
|
|
|
|
5
|
|
|
use InFw\TacticianAdapter\Factory\CommandBusFactory; |
6
|
|
|
use InFw\TacticianAdapter\Factory\HandlerLocatorFactory; |
7
|
|
|
use InFw\TacticianAdapter\Factory\LoggerMiddlewareFactory; |
8
|
|
|
use InFw\TacticianAdapter\Factory\QueryBusFactory; |
9
|
|
|
use League\Tactician\CommandBus; |
10
|
|
|
use League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor; |
11
|
|
|
use League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor; |
12
|
|
|
use League\Tactician\Handler\Locator\HandlerLocator; |
13
|
|
|
use League\Tactician\Handler\MethodNameInflector\InvokeInflector; |
14
|
|
|
use League\Tactician\Handler\MethodNameInflector\MethodNameInflector; |
15
|
|
|
use League\Tactician\Logger\Formatter\ClassPropertiesFormatter; |
16
|
|
|
use League\Tactician\Logger\Formatter\Formatter; |
17
|
|
|
use League\Tactician\Logger\LoggerMiddleware; |
18
|
|
|
use League\Tactician\Plugins\LockingMiddleware; |
19
|
|
|
|
20
|
|
|
class ConfigProvider |
21
|
|
|
{ |
22
|
|
|
public function __invoke() |
23
|
|
|
{ |
24
|
|
|
return [ |
25
|
|
|
'command_bus' => $this->getBusConfig(), |
26
|
|
|
'query_bus' => $this->getQueryBusConfig(), |
27
|
|
|
'dependencies' => $this->getDependencies(), |
28
|
|
|
]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
protected function getBusConfig(): array |
32
|
|
|
{ |
33
|
|
|
return [ |
34
|
|
|
'locator' => HandlerLocator::class, |
35
|
|
|
'inflector' => MethodNameInflector::class, |
36
|
|
|
'extractor' => CommandNameExtractor::class, |
37
|
|
|
'formatter' => Formatter::class, |
38
|
|
|
'middleware' => [ |
39
|
|
|
LockingMiddleware::class => LockingMiddleware::class, |
40
|
|
|
LoggerMiddleware::class => LoggerMiddleware::class, |
41
|
|
|
], |
42
|
|
|
'handler_map' => [], |
43
|
|
|
]; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
protected function getQueryBusConfig(): array |
47
|
|
|
{ |
48
|
|
|
return [ |
49
|
|
|
'locator' => 'query_bus.handler_locator', |
50
|
|
|
'inflector' => MethodNameInflector::class, |
51
|
|
|
'extractor' => CommandNameExtractor::class, |
52
|
|
|
'formatter' => Formatter::class, |
53
|
|
|
'middleware' => [], |
54
|
|
|
'handler_map' => [], |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function getDependencies(): array |
59
|
|
|
{ |
60
|
|
|
return [ |
61
|
|
|
'invokables' => [ |
62
|
|
|
Formatter::class => ClassPropertiesFormatter::class, |
63
|
|
|
MethodNameInflector::class => InvokeInflector::class, |
64
|
|
|
CommandNameExtractor::class => ClassNameExtractor::class, |
65
|
|
|
LockingMiddleware::class => LockingMiddleware::class, |
66
|
|
|
], |
67
|
|
|
'factories' => [ |
68
|
|
|
CommandBus::class => CommandBusFactory::class, |
69
|
|
|
QueryBus::class => QueryBusFactory::class, |
70
|
|
|
HandlerLocator::class => [HandlerLocatorFactory::class, 'command_bus'], |
71
|
|
|
'query_bus.handler_locator' => [HandlerLocatorFactory::class, 'query_bus'], |
72
|
|
|
LoggerMiddleware::class => LoggerMiddlewareFactory::class, |
73
|
|
|
], |
74
|
|
|
]; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|