-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathConfigProvider.php
93 lines (86 loc) · 3.12 KB
/
ConfigProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
declare(strict_types=1);
namespace Netglue\PsrContainer\Messenger;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Laminas\ServiceManager\ServiceManager;
use Symfony\Component\Messenger as SymfonyMessenger;
use Symfony\Component\Messenger\Handler\HandlersLocatorInterface;
/**
* @psalm-import-type ServiceManagerConfiguration from ServiceManager
* @psalm-type RetryStrategyConfig = array{
* service?: string|null,
* max_retries?: numeric|null,
* delay?: numeric|null,
* multiplier?: numeric|null,
* max_delay?: numeric|null,
* }
* @psalm-type TransportSetup = array{
* dsn: non-empty-string,
* retry_strategy?: RetryStrategyConfig,
* failure_transport?: non-empty-string|null,
* }
* @psalm-type BusConfig = array{
* allows_zero_handlers: bool,
* middleware: list<string>,
* handler_locator: class-string<HandlersLocatorInterface>,
* handlers: array<string, string|list<string>>,
* routes: array<string, list<string>>,
* logger?: string|null,
* }
* @psalm-type MessengerConfig = array{
* logger?: string|null,
* failure_transport?: string|null,
* buses: array<string, BusConfig>,
* transports: array<string, TransportSetup>,
* }
*/
final class ConfigProvider
{
/** @return array<string, mixed> */
public function __invoke(): array
{
return [
'dependencies' => $this->dependencies(),
'symfony' => [
'messenger' => $this->messengerConfig(),
],
'laminas-cli' => $this->consoleConfig(),
];
}
/** @return ServiceManagerConfiguration */
private function dependencies(): array
{
return [
'factories' => [
Container\FailureReceiversProvider::class => Container\FailureReceiversProviderFactory::class,
Container\FailureSendersProvider::class => Container\FailureSendersProviderFactory::class,
SymfonyMessenger\Command\ConsumeMessagesCommand::class => Container\Command\ConsumeCommandFactory::class,
SymfonyMessenger\Command\DebugCommand::class => Container\Command\DebugCommandFactory::class,
RetryStrategyContainer::class => Container\RetryStrategyContainerFactory::class,
TransportFactoryFactory::class => InvokableFactory::class,
],
];
}
/** @return MessengerConfig */
private function messengerConfig(): array
{
return [
// This logger is used by the console commands:
'logger' => null,
// The name of the failure transport should be retrievable by name from the container:
'failure_transport' => null, //'failed',
'buses' => [],
'transports' => [],
];
}
/** @return array<string, array<string, class-string>> */
private function consoleConfig(): array
{
return [
'commands' => [
'messenger:consume' => SymfonyMessenger\Command\ConsumeMessagesCommand::class,
'debug:messenger' => SymfonyMessenger\Command\DebugCommand::class,
],
];
}
}