123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Symfony\Component\Config\Definition\Builder;
- use Symfony\Component\Config\Definition\NodeInterface;
- class TreeBuilder implements NodeParentInterface
- {
- protected $tree;
- protected $root;
- protected $builder;
-
- public function root($name, $type = 'array', NodeBuilder $builder = null)
- {
- $builder = $builder ?: new NodeBuilder();
- return $this->root = $builder->node($name, $type)->setParent($this);
- }
-
- 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);
- }
- }
|