mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 19:48:49 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -23,27 +23,18 @@ class TreeBuilder implements NodeParentInterface
|
||||
protected $tree;
|
||||
protected $root;
|
||||
|
||||
/**
|
||||
* @deprecated since 3.4. To be removed in 4.0
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
/**
|
||||
* Creates the root node.
|
||||
*
|
||||
* @param string $name The name of the root node
|
||||
* @param string $type The type of the root node
|
||||
* @param NodeBuilder $builder A custom node builder instance
|
||||
*
|
||||
* @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not supported
|
||||
*/
|
||||
public function root($name, $type = 'array', NodeBuilder $builder = null)
|
||||
public function __construct(string $name, string $type = 'array', NodeBuilder $builder = null)
|
||||
{
|
||||
$builder = $builder ?: new NodeBuilder();
|
||||
$builder = $builder ?? new NodeBuilder();
|
||||
$this->root = $builder->node($name, $type)->setParent($this);
|
||||
}
|
||||
|
||||
return $this->root = $builder->node($name, $type)->setParent($this);
|
||||
/**
|
||||
* @return NodeDefinition|ArrayNodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
|
||||
*/
|
||||
public function getRootNode(): NodeDefinition
|
||||
{
|
||||
return $this->root;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,13 +46,18 @@ class TreeBuilder implements NodeParentInterface
|
||||
*/
|
||||
public function buildTree()
|
||||
{
|
||||
if (null === $this->root) {
|
||||
throw new \RuntimeException('The configuration tree has no root node.');
|
||||
}
|
||||
if (null !== $this->tree) {
|
||||
return $this->tree;
|
||||
}
|
||||
|
||||
return $this->tree = $this->root->getNode(true);
|
||||
}
|
||||
|
||||
public function setPathSeparator(string $separator)
|
||||
{
|
||||
// unset last built as changing path separator changes all nodes
|
||||
$this->tree = null;
|
||||
|
||||
$this->root->setPathSeparator($separator);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user