Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • ArrayNodeDefinition
  • BooleanNodeDefinition
  • EnumNodeDefinition
  • ExprBuilder
  • FloatNodeDefinition
  • IntegerNodeDefinition
  • MergeBuilder
  • NodeBuilder
  • NodeDefinition
  • NormalizationBuilder
  • NumericNodeDefinition
  • ScalarNodeDefinition
  • TreeBuilder
  • ValidationBuilder
  • VariableNodeDefinition

Interfaces

  • NodeParentInterface
  • ParentNodeDefinitionInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: /*
 4:  * This file is part of the Symfony package.
 5:  *
 6:  * (c) Fabien Potencier <fabien@symfony.com>
 7:  *
 8:  * For the full copyright and license information, please view the LICENSE
 9:  * file that was distributed with this source code.
10:  */
11: 
12: namespace Symfony\Component\Config\Definition\Builder;
13: 
14: use Symfony\Component\Config\Definition\NodeInterface;
15: 
16: /**
17:  * This is the entry class for building a config tree.
18:  *
19:  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
20:  */
21: class TreeBuilder implements NodeParentInterface
22: {
23:     protected $tree;
24:     protected $root;
25:     protected $builder;
26: 
27:     /**
28:      * Creates the root node.
29:      *
30:      * @param string      $name    The name of the root node
31:      * @param string      $type    The type of the root node
32:      * @param NodeBuilder $builder A custom node builder instance
33:      *
34:      * @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
35:      *
36:      * @throws \RuntimeException When the node type is not supported
37:      */
38:     public function root($name, $type = 'array', NodeBuilder $builder = null)
39:     {
40:         $builder = $builder ?: new NodeBuilder();
41: 
42:         return $this->root = $builder->node($name, $type)->setParent($this);
43:     }
44: 
45:     /**
46:      * Builds the tree.
47:      *
48:      * @return NodeInterface
49:      *
50:      * @throws \RuntimeException
51:      */
52:     public function buildTree()
53:     {
54:         if (null === $this->root) {
55:             throw new \RuntimeException('The configuration tree has no root node.');
56:         }
57:         if (null !== $this->tree) {
58:             return $this->tree;
59:         }
60: 
61:         return $this->tree = $this->root->getNode(true);
62:     }
63: }
64: 
php-coveralls API documentation generated by ApiGen 2.8.0