2
2
3
3
namespace Enqueue \Bundle \DependencyInjection ;
4
4
5
+ use Enqueue \Monitoring \Symfony \DependencyInjection \MonitoringFactory ;
5
6
use Enqueue \Symfony \Client \DependencyInjection \ClientFactory ;
6
7
use Enqueue \Symfony \DependencyInjection \TransportFactory ;
7
8
use Symfony \Component \Config \Definition \Builder \ArrayNodeDefinition ;
@@ -26,8 +27,8 @@ public function getConfigTreeBuilder(): TreeBuilder
26
27
->always (function ($ value ) {
27
28
if (empty ($ value )) {
28
29
return [
29
- 'transport ' => [
30
- 'default ' => [
30
+ 'default ' => [
31
+ 'transport ' => [
31
32
'dsn ' => 'null: ' ,
32
33
],
33
34
],
@@ -36,8 +37,8 @@ public function getConfigTreeBuilder(): TreeBuilder
36
37
37
38
if (is_string ($ value )) {
38
39
return [
39
- 'transport ' => [
40
- 'default ' => [
40
+ 'default ' => [
41
+ 'transport ' => [
41
42
'dsn ' => $ value ,
42
43
],
43
44
],
@@ -50,57 +51,82 @@ public function getConfigTreeBuilder(): TreeBuilder
50
51
51
52
$ transportFactory = new TransportFactory ('default ' );
52
53
53
- /** @var ArrayNodeDefinition $transportNode */
54
- $ transportNode = $ rootNode ->children ()->arrayNode ('transport ' );
55
- $ transportNode
56
- ->beforeNormalization ()
57
- ->always (function ($ value ) {
58
- if (empty ($ value )) {
59
- return ['default ' => ['dsn ' => 'null: ' ]];
60
- }
61
- if (is_string ($ value )) {
62
- return ['default ' => ['dsn ' => $ value ]];
63
- }
64
-
65
- if (is_array ($ value ) && array_key_exists ('dsn ' , $ value )) {
66
- return ['default ' => $ value ];
67
- }
68
-
69
- return $ value ;
70
- });
71
- $ transportPrototypeNode = $ transportNode
72
- ->requiresAtLeastOneElement ()
73
- ->useAttributeAsKey ('key ' )
74
- ->prototype ('array ' )
75
- ;
54
+ $ transportConfig = $ transportFactory ->getConfiguration ('transport ' );
55
+ $ transportConfig ->isRequired ();
76
56
77
- $ transportFactory ->addTransportConfiguration ( $ transportPrototypeNode );
57
+ $ consumerConfig = $ transportFactory ->getQueueConsumerConfiguration ( ' consumption ' );
78
58
79
- $ consumptionNode = $ rootNode ->children ()->arrayNode ('consumption ' );
80
- $ transportFactory ->addQueueConsumerConfiguration ($ consumptionNode );
59
+ $ clientConfig = (new ClientFactory ('default ' ))->getConfiguration ('client ' , $ this ->debug );
81
60
82
- $ clientFactory = new ClientFactory ('default ' );
83
- $ clientNode = $ rootNode ->children ()->arrayNode ('client ' );
84
- $ clientFactory ->addClientConfiguration ($ clientNode , $ this ->debug );
61
+ $ monitoringConfig = (new MonitoringFactory ('default ' ))->getConfiguration ('monitoring ' );
85
62
86
- $ rootNode ->children ()
87
- ->booleanNode ('job ' )->defaultFalse ()->end ()
88
- ->arrayNode ('async_events ' )
89
- ->addDefaultsIfNotSet ()
90
- ->canBeEnabled ()
91
- ->end ()
92
- ->arrayNode ('async_commands ' )
93
- ->addDefaultsIfNotSet ()
94
- ->canBeEnabled ()
63
+ $ rootNode
64
+ ->requiresAtLeastOneElement ()
65
+ ->useAttributeAsKey ('key ' )
66
+ ->arrayPrototype ()
67
+ ->children ()
68
+ ->append ($ transportConfig )
69
+ ->append ($ consumerConfig )
70
+ ->append ($ clientConfig )
71
+ ->append ($ monitoringConfig )
72
+ ->end ()
95
73
->end ()
96
- ->arrayNode ('extensions ' )->addDefaultsIfNotSet ()->children ()
97
- ->booleanNode ('doctrine_ping_connection_extension ' )->defaultFalse ()->end ()
98
- ->booleanNode ('doctrine_clear_identity_map_extension ' )->defaultFalse ()->end ()
99
- ->booleanNode ('signal_extension ' )->defaultValue (function_exists ('pcntl_signal_dispatch ' ))->end ()
100
- ->booleanNode ('reply_extension ' )->defaultTrue ()->end ()
101
- ->end ()->end ()
102
74
;
103
75
76
+
77
+ // $transportFactory = new TransportFactory('default');
78
+ //
79
+ // /** @var ArrayNodeDefinition $transportNode */
80
+ // $transportNode = $rootNode->children()->arrayNode('transport');
81
+ // $transportNode
82
+ // ->beforeNormalization()
83
+ // ->always(function ($value) {
84
+ // if (empty($value)) {
85
+ // return ['default' => ['dsn' => 'null:']];
86
+ // }
87
+ // if (is_string($value)) {
88
+ // return ['default' => ['dsn' => $value]];
89
+ // }
90
+ //
91
+ // if (is_array($value) && array_key_exists('dsn', $value)) {
92
+ // return ['default' => $value];
93
+ // }
94
+ //
95
+ // return $value;
96
+ // });
97
+ // $transportPrototypeNode = $transportNode
98
+ // ->requiresAtLeastOneElement()
99
+ // ->useAttributeAsKey('key')
100
+ // ->prototype('array')
101
+ // ;
102
+ //
103
+ // $transportFactory->addTransportConfiguration($transportPrototypeNode);
104
+ //
105
+ // $consumptionNode = $rootNode->children()->arrayNode('consumption');
106
+ // $transportFactory->addQueueConsumerConfiguration($consumptionNode);
107
+ //
108
+ // $clientFactory = new ClientFactory('default');
109
+ // $clientNode = $rootNode->children()->arrayNode('client');
110
+ // $clientFactory->addClientConfiguration($clientNode, $this->debug);
111
+ //
112
+ // $rootNode->children()
113
+ // ->booleanNode('job')->defaultFalse()->end()
114
+ // ->arrayNode('async_events')
115
+ // ->addDefaultsIfNotSet()
116
+ // ->canBeEnabled()
117
+ // ->end()
118
+ // ->arrayNode('async_commands')
119
+ // ->addDefaultsIfNotSet()
120
+ // ->canBeEnabled()
121
+ // ->end()
122
+ // ->arrayNode('extensions')->addDefaultsIfNotSet()->children()
123
+ // ->booleanNode('doctrine_ping_connection_extension')->defaultFalse()->end()
124
+ // ->booleanNode('doctrine_clear_identity_map_extension')->defaultFalse()->end()
125
+ // ->booleanNode('signal_extension')->defaultValue(function_exists('pcntl_signal_dispatch'))->end()
126
+ // ->booleanNode('reply_extension')->defaultTrue()->end()
127
+ // ->end()->end()
128
+ // ;
129
+ //
104
130
return $ tb ;
105
131
}
106
132
}
0 commit comments