|
0
|
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 |
use Symfony\Component\Config\Definition\VariableNode; |
|
|
16 |
|
|
|
17 |
/** |
|
|
18 |
* This class provides a fluent interface for defining a node. |
|
|
19 |
* |
|
|
20 |
* @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
|
21 |
*/ |
|
|
22 |
class VariableNodeDefinition extends NodeDefinition |
|
|
23 |
{ |
|
|
24 |
/** |
|
|
25 |
* Instantiate a Node |
|
|
26 |
* |
|
|
27 |
* @return VariableNode The node |
|
|
28 |
*/ |
|
|
29 |
protected function instantiateNode() |
|
|
30 |
{ |
|
|
31 |
return new VariableNode($this->name, $this->parent); |
|
|
32 |
} |
|
|
33 |
|
|
|
34 |
/** |
|
|
35 |
* {@inheritDoc} |
|
|
36 |
*/ |
|
|
37 |
protected function createNode() |
|
|
38 |
{ |
|
|
39 |
$node = $this->instantiateNode(); |
|
|
40 |
|
|
|
41 |
if (null !== $this->normalization) { |
|
|
42 |
$node->setNormalizationClosures($this->normalization->before); |
|
|
43 |
} |
|
|
44 |
|
|
|
45 |
if (null !== $this->merge) { |
|
|
46 |
$node->setAllowOverwrite($this->merge->allowOverwrite); |
|
|
47 |
} |
|
|
48 |
|
|
|
49 |
if (true === $this->default) { |
|
|
50 |
$node->setDefaultValue($this->defaultValue); |
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
if (false === $this->allowEmptyValue) { |
|
|
54 |
$node->setAllowEmptyValue($this->allowEmptyValue); |
|
|
55 |
} |
|
|
56 |
|
|
|
57 |
$node->addEquivalentValue(null, $this->nullEquivalent); |
|
|
58 |
$node->addEquivalentValue(true, $this->trueEquivalent); |
|
|
59 |
$node->addEquivalentValue(false, $this->falseEquivalent); |
|
|
60 |
$node->setRequired($this->required); |
|
|
61 |
|
|
|
62 |
if (null !== $this->validation) { |
|
|
63 |
$node->setFinalValidationClosures($this->validation->rules); |
|
|
64 |
} |
|
|
65 |
|
|
|
66 |
return $node; |
|
|
67 |
} |
|
|
68 |
|
|
|
69 |
} |