1
1
.. index ::
2
2
single: Config; Defining and processing configuration values
3
3
4
- Defining and processing configuration values
4
+ Defining and Processing Configuration Values
5
5
============================================
6
6
7
- Validating configuration values
7
+ Validating Configuration Values
8
8
-------------------------------
9
9
10
10
After loading configuration values from all kinds of resources, the values
@@ -38,7 +38,7 @@ they are when first encountered. Also, some keys are only available when
38
38
another key has a specific value (in the sample configuration above: the
39
39
``memory `` key only makes sense when the ``driver `` is ``sqlite ``).
40
40
41
- Defining a hierarchy of configuration values using the TreeBuilder
41
+ Defining a Hierarchy of Configuration Values Using the TreeBuilder
42
42
------------------------------------------------------------------
43
43
44
44
All the rules concerning configuration values can be defined using the
@@ -66,10 +66,10 @@ should be returned from a custom ``Configuration`` class which implements the
66
66
}
67
67
}
68
68
69
- Adding node definitions to the tree
69
+ Adding Node Definitions to the Tree
70
70
-----------------------------------
71
71
72
- Variable nodes
72
+ Variable Nodes
73
73
~~~~~~~~~~~~~~
74
74
75
75
A tree contains node definitions which can be laid out in a semantic way.
@@ -91,7 +91,7 @@ The root node itself is an array node, and has children, like the boolean
91
91
node ``auto_connect `` and the scalar node ``default_connection ``. In general:
92
92
after defining a node, a call to ``end() `` takes you one step up in the hierarchy.
93
93
94
- Node type
94
+ Node Type
95
95
~~~~~~~~~
96
96
97
97
It is possible to validate the type of a provided value by using the appropriate
@@ -108,11 +108,11 @@ node definition. Node type are available for:
108
108
and are created with ``node($name, $type) `` or their associated shortcut
109
109
``xxxxNode($name) `` method.
110
110
111
- Numeric node constraints
111
+ Numeric Node Constraints
112
112
~~~~~~~~~~~~~~~~~~~~~~~~
113
113
114
114
.. versionadded :: 2.2
115
- The numeric (float and integer) nodes are new in 2.2
115
+ The numeric (float and integer) nodes were introduced in Symfony 2.2.
116
116
117
117
Numeric nodes (float and integer) provide two extra constraints -
118
118
:method: `Symfony\\ Component\\ Config\\ Definition\\ Builder::min ` and
@@ -133,7 +133,7 @@ allowing to validate the value::
133
133
->end()
134
134
;
135
135
136
- Enum nodes
136
+ Enum Nodes
137
137
~~~~~~~~~~
138
138
139
139
Enum nodes provide a constraint to match the given input against a set of
@@ -149,7 +149,7 @@ values::
149
149
150
150
This will restrict the ``gender `` option to be either ``male `` or ``female ``.
151
151
152
- Array nodes
152
+ Array Nodes
153
153
~~~~~~~~~~~
154
154
155
155
It is possible to add a deeper level to the hierarchy, by adding an array
@@ -190,7 +190,7 @@ inside the current node. According to the prototype definition in the example
190
190
above, it is possible to have multiple connection arrays (containing a ``driver ``,
191
191
``host ``, etc.).
192
192
193
- Array node options
193
+ Array Node Options
194
194
~~~~~~~~~~~~~~~~~~
195
195
196
196
Before defining the children of an array node, you can provide options like:
@@ -233,7 +233,7 @@ In XML, each ``parameters`` node would have a ``name`` attribute (along with
233
233
the final array. The ``useAttributeAsKey `` is useful for normalizing how
234
234
arrays are specified between different formats like XML and YAML.
235
235
236
- Default and required values
236
+ Default and required Values
237
237
---------------------------
238
238
239
239
For all node types, it is possible to define default values and replacement
@@ -288,7 +288,8 @@ Optional Sections
288
288
-----------------
289
289
290
290
.. versionadded :: 2.2
291
- The ``canBeEnabled `` and ``canBeDisabled `` methods are new in Symfony 2.2
291
+ The ``canBeEnabled `` and ``canBeDisabled `` methods were introduced in
292
+ Symfony 2.2.
292
293
293
294
If you have entire sections which are optional and can be enabled/disabled,
294
295
you can take advantage of the shortcut
@@ -313,7 +314,7 @@ you can take advantage of the shortcut
313
314
The ``canBeDisabled `` method looks about the same except that the section
314
315
would be enabled by default.
315
316
316
- Merging options
317
+ Merging Options
317
318
---------------
318
319
319
320
Extra options concerning the merge process may be provided. For arrays:
@@ -327,7 +328,7 @@ For all nodes:
327
328
``cannotBeOverwritten() ``
328
329
don’t let other configuration arrays overwrite an existing value for this node
329
330
330
- Appending sections
331
+ Appending Sections
331
332
------------------
332
333
333
334
If you have a complex configuration to validate then the tree can grow to
@@ -499,7 +500,7 @@ By changing a string value into an associative array with ``name`` as the key::
499
500
->end()
500
501
;
501
502
502
- Validation rules
503
+ Validation Rules
503
504
----------------
504
505
505
506
More advanced validation rules can be provided using the
@@ -545,7 +546,7 @@ Usually, "then" is a closure. Its return value will be used as a new value
545
546
for the node, instead
546
547
of the node's original value.
547
548
548
- Processing configuration values
549
+ Processing Configuration Values
549
550
-------------------------------
550
551
551
552
The :class: `Symfony\\ Component\\ Config\\ Definition\\ Processor ` uses the tree
0 commit comments