From a374aaa89320dcd4e56c2039f6e2dc988ffdf15c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 11 Oct 2017 15:53:42 +0200 Subject: [PATCH 1/2] Documented the new config prototype shortcuts --- components/config/definition.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/components/config/definition.rst b/components/config/definition.rst index 957e4e61a1a..a5f8c56b1cb 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -174,7 +174,7 @@ Or you may define a prototype for each node inside an array node:: $rootNode ->children() ->arrayNode('connections') - ->prototype('array') + ->arrayPrototype() ->children() ->scalarNode('driver')->end() ->scalarNode('host')->end() @@ -186,6 +186,12 @@ Or you may define a prototype for each node inside an array node:: ->end() ; +.. versionadded:: 3.3 + The ``arrayPrototype()`` method (and the related ``booleanPrototype()`` + ``integerPrototype()``, ``floatPrototype()``, ``scalarPrototype()`` and + ``enumPrototype()``) was introduced in Symfony 3.3. In previous versions, + you needed to use ``prototype('array')``, ``prototype('boolean')``, etc.) + A prototype can be used to add a definition which may be repeated many times inside the current node. According to the prototype definition in the example above, it is possible to have multiple connection arrays (containing a ``driver``, @@ -229,7 +235,7 @@ A basic prototyped array configuration can be defined as follows:: ->fixXmlConfig('driver') ->children() ->arrayNode('drivers') - ->prototype('scalar')->end() + ->scalarPrototype()->end() ->end() ->end() ; @@ -260,7 +266,7 @@ A more complex example would be to define a prototyped array with children:: ->fixXmlConfig('connection') ->children() ->arrayNode('connections') - ->prototype('array') + ->arrayPrototype() ->children() ->scalarNode('table')->end() ->scalarNode('user')->end() @@ -334,7 +340,7 @@ In order to maintain the array keys use the ``useAttributeAsKey()`` method:: ->children() ->arrayNode('connections') ->useAttributeAsKey('name') - ->prototype('array') + ->arrayPrototype() ->children() ->scalarNode('table')->end() ->scalarNode('user')->end() @@ -549,7 +555,7 @@ tree with ``append()``:: ->isRequired() ->requiresAtLeastOneElement() ->useAttributeAsKey('name') - ->prototype('array') + ->arrayPrototype ->children() ->scalarNode('value')->isRequired()->end() ->end() @@ -647,7 +653,7 @@ with ``fixXmlConfig()``:: ->fixXmlConfig('extension') ->children() ->arrayNode('extensions') - ->prototype('scalar')->end() + ->scalarPrototype()->end() ->end() ->end() ; From 1f6d300a62561edbf081f92c6e71de2b9fb6069d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 13 Oct 2017 11:31:12 +0200 Subject: [PATCH 2/2] Fixed typo --- components/config/definition.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/config/definition.rst b/components/config/definition.rst index a5f8c56b1cb..a4890c4d47d 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -190,7 +190,7 @@ Or you may define a prototype for each node inside an array node:: The ``arrayPrototype()`` method (and the related ``booleanPrototype()`` ``integerPrototype()``, ``floatPrototype()``, ``scalarPrototype()`` and ``enumPrototype()``) was introduced in Symfony 3.3. In previous versions, - you needed to use ``prototype('array')``, ``prototype('boolean')``, etc.) + you needed to use ``prototype('array')``, ``prototype('boolean')``, etc. A prototype can be used to add a definition which may be repeated many times inside the current node. According to the prototype definition in the example