1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Neo4j\Neo4jBundle\DependencyInjection; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
8
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* This class contains the configuration information for the bundle. |
12
|
|
|
* |
13
|
|
|
* This information is solely responsible for how the different configuration |
14
|
|
|
* sections are normalized, and merged. |
15
|
|
|
* |
16
|
|
|
* @author Tobias Nyholm <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
class Configuration implements ConfigurationInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Whether to use the debug mode. |
22
|
|
|
* |
23
|
|
|
* @see https://github.com/doctrine/DoctrineBundle/blob/v1.5.2/DependencyInjection/Configuration.php#L31-L41 |
24
|
|
|
* |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
private $debug; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param bool $debug |
31
|
|
|
*/ |
32
|
6 |
|
public function __construct($debug) |
33
|
|
|
{ |
34
|
6 |
|
$this->debug = (bool) $debug; |
35
|
6 |
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
6 |
|
public function getConfigTreeBuilder() |
41
|
|
|
{ |
42
|
6 |
|
$treeBuilder = new TreeBuilder('neo4j'); |
43
|
|
|
// Keep compatibility with symfony/config < 4.2 |
44
|
6 |
|
if (!method_exists($treeBuilder, 'getRootNode')) { |
45
|
|
|
$root = $treeBuilder->root('neo4j'); |
|
|
|
|
46
|
|
|
} else { |
47
|
6 |
|
$root = $treeBuilder->getRootNode(); |
48
|
|
|
} |
49
|
|
|
|
50
|
6 |
|
$root->children() |
51
|
6 |
|
->arrayNode('profiling') |
52
|
6 |
|
->addDefaultsIfNotSet() |
53
|
6 |
|
->treatFalseLike(['enabled' => false]) |
54
|
6 |
|
->treatTrueLike(['enabled' => true]) |
55
|
6 |
|
->treatNullLike(['enabled' => $this->debug]) |
56
|
6 |
|
->info('Extend the web profiler with information about queries.') |
57
|
6 |
|
->children() |
58
|
6 |
|
->booleanNode('enabled') |
59
|
6 |
|
->info('Turn the toolbar on or off. Defaults to kernel debug mode.') |
60
|
6 |
|
->defaultValue($this->debug) |
61
|
6 |
|
->end() |
62
|
6 |
|
->end() |
63
|
6 |
|
->end() |
64
|
6 |
|
->arrayNode('clients') |
65
|
6 |
|
->requiresAtLeastOneElement() |
66
|
6 |
|
->useAttributeAsKey('name') |
67
|
6 |
|
->prototype('array') |
68
|
6 |
|
->addDefaultsIfNotSet() |
69
|
6 |
|
->fixXmlConfig('connection') |
70
|
6 |
|
->children() |
71
|
6 |
|
->arrayNode('connections') |
72
|
6 |
|
->prototype('scalar')->end() |
73
|
6 |
|
->end() |
74
|
6 |
|
->end() |
75
|
6 |
|
->end()->end() |
76
|
6 |
|
->arrayNode('entity_managers') |
77
|
6 |
|
->requiresAtLeastOneElement() |
78
|
6 |
|
->useAttributeAsKey('name') |
79
|
6 |
|
->prototype('array') |
80
|
6 |
|
->addDefaultsIfNotSet() |
81
|
6 |
|
->children() |
82
|
6 |
|
->scalarNode('client')->defaultValue('default')->end() |
83
|
6 |
|
->scalarNode('cache_dir')->defaultNull()->end() |
84
|
6 |
|
->end() |
85
|
6 |
|
->end()->end() |
86
|
6 |
|
->arrayNode('connections') |
87
|
6 |
|
->isRequired() |
88
|
6 |
|
->requiresAtLeastOneElement() |
89
|
6 |
|
->useAttributeAsKey('name') |
90
|
6 |
|
->prototype('array') |
91
|
6 |
|
->addDefaultsIfNotSet() |
92
|
6 |
|
->children() |
93
|
6 |
|
->enumNode('scheme')->values(['http', 'bolt'])->defaultValue('bolt')->end() |
94
|
6 |
|
->scalarNode('host')->defaultValue('localhost')->end() |
95
|
6 |
|
->scalarNode('port')->end() |
96
|
6 |
|
->scalarNode('username')->defaultValue('neo4j')->end() |
97
|
6 |
|
->scalarNode('password')->defaultValue('neo4j')->end() |
98
|
6 |
|
->scalarNode('dsn')->defaultNull()->end() |
99
|
6 |
|
->end() |
100
|
6 |
|
->end() |
101
|
6 |
|
->end(); |
102
|
|
|
|
103
|
6 |
|
return $treeBuilder; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.