Skip to content

Commit 7fb2322

Browse files
committed
[Config] Allow changing the path separator
1 parent 9111bd2 commit 7fb2322

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

components/config/definition.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,48 @@ A validation rule also requires a "then" part:
788788
Usually, "then" is a closure. Its return value will be used as a new value
789789
for the node, instead of the node's original value.
790790

791+
Configuring the Node Path Separator
792+
-----------------------------------
793+
794+
.. versionadded:: 4.1
795+
The option to configure the node path separator was introduced in Symfony 4.1.
796+
797+
Consider the following config builder example::
798+
799+
$treeBuilder = new TreeBuilder();
800+
$rootNode = $treeBuilder->root('database');
801+
802+
$rootNode
803+
->children()
804+
->arrayNode('connection')
805+
->children()
806+
->scalarNode('driver')->end()
807+
->end()
808+
->end()
809+
->end()
810+
;
811+
812+
By default, the hierarchy of nodes in a config path is defined with a dot
813+
character (``.``)::
814+
815+
// ...
816+
817+
$node = $treeBuilder->buildTree();
818+
$children = $node->getChildren();
819+
$path = $children['driver']->getPath();
820+
// $path = 'database.connection.driver'
821+
822+
Use the ``setPathSeparator()`` method on the config builder to change the path
823+
separator::
824+
825+
// ...
826+
827+
$treeBuilder->setPathSeparator('/');
828+
$node = $treeBuilder->buildTree();
829+
$children = $node->getChildren();
830+
$path = $children['driver']->getPath();
831+
// $path = 'database/connection/driver'
832+
791833
Processing Configuration Values
792834
-------------------------------
793835

0 commit comments

Comments
 (0)