-
Notifications
You must be signed in to change notification settings - Fork 439
/
Copy pathConfiguration.php
79 lines (67 loc) · 2.85 KB
/
Configuration.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
<?php
namespace Enqueue\Bundle\DependencyInjection;
use Enqueue\AsyncCommand\RunCommandProcessor;
use Enqueue\Monitoring\Symfony\DependencyInjection\MonitoringFactory;
use Enqueue\Symfony\Client\DependencyInjection\ClientFactory;
use Enqueue\Symfony\DependencyInjection\TransportFactory;
use Enqueue\Symfony\MissingComponentFactory;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
final class Configuration implements ConfigurationInterface
{
private $debug;
public function __construct(bool $debug)
{
$this->debug = $debug;
}
public function getConfigTreeBuilder(): TreeBuilder
{
$tb = new TreeBuilder();
$rootNode = $tb->root('enqueue');
$rootNode
->requiresAtLeastOneElement()
->useAttributeAsKey('key')
->arrayPrototype()
->children()
->append(TransportFactory::getConfiguration())
->append(TransportFactory::getQueueConsumerConfiguration())
->append(ClientFactory::getConfiguration($this->debug))
->append($this->getMonitoringConfiguration())
->append($this->getAsyncCommandsConfiguration())
->arrayNode('extensions')->addDefaultsIfNotSet()->children()
->booleanNode('doctrine_ping_connection_extension')->defaultFalse()->end()
->booleanNode('doctrine_clear_identity_map_extension')->defaultFalse()->end()
->booleanNode('signal_extension')->defaultValue(function_exists('pcntl_signal_dispatch'))->end()
->booleanNode('reply_extension')->defaultTrue()->end()
->end()->end()
->end()
->end()
;
// $rootNode->children()
// ->booleanNode('job')->defaultFalse()->end()
// ->arrayNode('async_events')
// ->addDefaultsIfNotSet()
// ->canBeEnabled()
// ->end()
// ;
return $tb;
}
private function getMonitoringConfiguration(): ArrayNodeDefinition
{
if (false === class_exists(MonitoringFactory::class)) {
return MissingComponentFactory::getConfiguration('monitoring', ['enqueue/monitoring']);
}
return MonitoringFactory::getConfiguration();
}
private function getAsyncCommandsConfiguration(): ArrayNodeDefinition
{
if (false === class_exists(RunCommandProcessor::class)) {
return MissingComponentFactory::getConfiguration('async_commands', ['enqueue/async-command']);
}
return (new ArrayNodeDefinition('async_commands'))
->addDefaultsIfNotSet()
->canBeEnabled()
;
}
}