1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Antidot\Tactician\Container\Config; |
4
|
|
|
|
5
|
|
|
use Antidot\Tactician\Container\CommandBusFactory; |
6
|
|
|
use Antidot\Tactician\Container\HandlerLocatorFactory; |
7
|
|
|
use Antidot\Tactician\Container\QueryBusFactory; |
8
|
|
|
use Antidot\Tactician\QueryBus; |
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\Plugins\LockingMiddleware; |
16
|
|
|
|
17
|
|
|
class ConfigProvider |
18
|
|
|
{ |
19
|
|
|
public const COMMAND_BUS = [ |
20
|
|
|
'locator' => HandlerLocator::class, |
21
|
|
|
'inflector' => MethodNameInflector::class, |
22
|
|
|
'extractor' => CommandNameExtractor::class, |
23
|
|
|
'middleware' => [ |
24
|
|
|
LockingMiddleware::class => LockingMiddleware::class, |
25
|
|
|
], |
26
|
|
|
'handler_map' => [ |
27
|
|
|
], |
28
|
|
|
]; |
29
|
|
|
public const QUERY_BUS = [ |
30
|
|
|
'locator' => 'query_bus.handler_locator', |
31
|
|
|
'inflector' => MethodNameInflector::class, |
32
|
|
|
'extractor' => CommandNameExtractor::class, |
33
|
|
|
'middleware' => [ |
34
|
|
|
], |
35
|
|
|
'handler_map' => [ |
36
|
|
|
], |
37
|
|
|
]; |
38
|
|
|
public const DEPENDENCIES = [ |
39
|
|
|
'factories' => [ |
40
|
|
|
CommandBus::class => CommandBusFactory::class, |
41
|
|
|
QueryBus::class => QueryBusFactory::class, |
42
|
|
|
HandlerLocator::class => [HandlerLocatorFactory::class, 'command_bus'], |
43
|
|
|
'query_bus.handler_locator' => [HandlerLocatorFactory::class, 'query_bus'], ], |
44
|
|
|
'invokables' => [ |
45
|
|
|
MethodNameInflector::class => InvokeInflector::class, |
46
|
|
|
CommandNameExtractor::class => ClassNameExtractor::class, |
47
|
|
|
LockingMiddleware::class => LockingMiddleware::class, |
48
|
|
|
], |
49
|
|
|
]; |
50
|
|
|
|
51
|
1 |
|
public function __invoke(): array |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
1 |
|
'command_bus' => self::COMMAND_BUS, |
55
|
1 |
|
'query_bus' => self::QUERY_BUS, |
56
|
1 |
|
'dependencies' => self::DEPENDENCIES, |
57
|
|
|
]; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|