8000 Add path separator knowledge for all node definitions · symfony/symfony@9f680c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f680c6

Browse files
committed
Add path separator knowledge for all node definitions
1 parent 7be490f commit 9f680c6

8 files changed

+33
-32
lines changed

src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct($name, NodeParentInterface $parent = null)
3838
*/
3939
protected function instantiateNode()
4040
{
41-
return new BooleanNode($this->name, $this->parent);
41+
return new BooleanNode($this->name, $this->parent, $this->getPathSeparator());
4242
}
4343

4444
/**

src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ protected function instantiateNode()
5353
throw new \RuntimeException('You must call ->values() on enum nodes.');
5454
}
5555

56-
return new EnumNode($this->name, $this->parent, $this->values);
56+
return new EnumNode($this->name, $this->parent, $this->values, $this->getPathSeparator());
5757
}
5858
}

src/Symfony/Component/Config/Definition/Builder/FloatNodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ class FloatNodeDefinition extends NumericNodeDefinition
2727
*/
2828
protected function instantiateNode()
2929
{
30-
return new FloatNode($this->name, $this->parent, $this->min, $this->max);
30+
return new FloatNode($this->name, $this->parent, $this->min, $this->max, $this->getPathSeparator());
3131
}
3232
}

src/Symfony/Component/Config/Definition/Builder/IntegerNodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ class IntegerNodeDefinition extends NumericNodeDefinition
2727
*/
2828
protected function instantiateNode()
2929
{
30-
return new IntegerNode($this->name, $this->parent, $this->min, $this->max);
30+
return new IntegerNode($this->name, $this->parent, $this->min, $this->max, $this->getPathSeparator());
3131
}
3232
}
< 10000 div aria-hidden="true" class="position-absolute top-0 d-flex user-select-none DiffLineTableCellParts-module__comment-indicator--eI0hb">

src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
2222
*/
23-
abstract class NodeDefinition implements NodeParentInterface, PathSeparatorAwareInterface
23+
abstract class NodeDefinition implements NodeParentInterface
2424
{
2525
private $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR;
2626
protected $name;
@@ -344,7 +344,11 @@ protected function normalization()
344344
abstract protected function createNode();
345345

346346
/**
347+
* Set PathSeparator to use
348+
*
347349
* @param string $separator
350+
*
351+
* @return $this
348352
*/
349353
public function setPathSeparator($separator)
350354
{
@@ -355,6 +359,8 @@ public function setPathSeparator($separator)
355359
}
356360

357361
$this->pathSeparator = $separator;
362+
363+
return $this;
358364
}
359365

360366
/**

src/Symfony/Component/Config/Definition/Builder/PathSeparatorAwareInterface.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Symfony/Component/Config/Definition/Builder/ScalarNodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ class ScalarNodeDefinition extends VariableNodeDefinition
2727
*/
2828
protected function instantiateNode()
2929
{
30-
return new ScalarNode($this->name, $this->parent);
30+
return new ScalarNode($this->name, $this->parent, $this->getPathSeparator());
3131
}
3232
}

src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,31 @@ public function root($name, $type = 'array', NodeBuilder $builder = null)
5757
*/
5858
public function buildTree()
5959
{
60-
if (null === $this->root) {
61-
throw new \RuntimeException('The configuration tree has no root node.');
62-
}
60+
$this->assertTreeHasRootNode();
6361
if (null !== $this->tree) {
6462
return $this->tree;
6563
}
6664

6765
return $this->tree = $this->root->getNode(true);
6866
}
67+
68+
public function setPathSeparator($separator)
69+
{
70+
$this->assertTreeHasRootNode();
71+
72+
// unset last built as changing path separator changes all nodes
73+
$this->tree = null;
74+
75+
$this->root->setPathSeparator($separator);
76+
}
77+
78+
/**
79+
* @throws \RuntimeException if root node is not defined.
80+
*/
81+
private function assertTreeHasRootNode()
82+
{
83+
if (null === $this->root) {
84+
throw new \RuntimeException('The configuration tree has no root node.');
85+
}
86+
}
6987
}

0 commit comments

Comments
 (0)
0