@@ -18,19 +18,19 @@ as integration of other related components:
|
18 | 18 | .. configuration-block::
|
19 | 19 |
|
20 | 20 | .. code-block:: yaml
|
21 |
| -
|
| 21 | +
|
22 | 22 | framework:
|
23 | 23 | # ...
|
24 | 24 | form: true
|
25 | 25 |
|
26 | 26 | .. code-block:: xml
|
27 |
| -
|
| 27 | +
|
28 | 28 | <framework:config>
|
29 | 29 | <framework:form />
|
30 | 30 | </framework:config>
|
31 | 31 |
|
32 | 32 | .. code-block:: php
|
33 |
| -
|
| 33 | +
|
34 | 34 | $container->loadFromExtension('framework', array(
|
35 | 35 | // ...
|
36 | 36 | 'form' => true,
|
@@ -304,7 +304,7 @@ option is passed and set to true::
|
304 | 304 | // prepare your $config variable
|
305 | 305 |
|
306 | 306 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
307 |
| -
|
| 307 | + |
308 | 308 | if (isset($config['enabled']) && $config['enabled']) {
|
309 | 309 | $loader->load('services.xml');
|
310 | 310 | }
|
@@ -470,7 +470,7 @@ that an unsupported option was passed::
|
470 | 470 | $processor = new Processor();
|
471 | 471 | $configuration = new Configuration();
|
472 | 472 | $config = $processor->processConfiguration($configuration, $configs);
|
473 |
| -
|
| 473 | + |
474 | 474 | // ...
|
475 | 475 | }
|
476 | 476 |
|
@@ -484,6 +484,54 @@ normalization and advanced merging. The best way to see this in action is
|
484 | 484 | to checkout out some of the core Configuration classes, such as the one from
|
485 | 485 | the `FrameworkBundle Configuration`_ or the `TwigBundle Configuration`_.
|
486 | 486 |
|
| 487 | +Default Configuration Dump |
| 488 | +~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 489 | + |
| 490 | +.. versionadded:: 2.1 |
| 491 | +The ``config:dump-reference`` command was added in Symfony 2.1 |
| 492 | + |
| 493 | +The ``config:dump-reference`` command allows a bundle's default configuration to |
| 494 | +be output to the console in yaml. |
| 495 | + |
| 496 | +As long as your bundle's configuration is located in the standard location |
| 497 | +(``YourBundle\DependencyInjection\Configuration``) and does not have a |
| 498 | +``__constructor()`` it will work automatically. If you have a something |
| 499 | +different your ``Extension`` class will have to override the |
| 500 | +``Extension::getConfiguration()`` method. Have it return an instance of your |
| 501 | +``Configuration``. |
| 502 | + |
| 503 | +Comments and examples can be added to your configuration nodes using the |
| 504 | +``->setInfo()`` and ``->setExample()`` methods:: |
| 505 | + |
| 506 | +// src/Acme/HelloBundle/DependencyExtension/Configuration.php |
| 507 | +namespace Acme\HelloBundle\DependencyInjection; |
| 508 | + |
| 509 | +use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
| 510 | +use Symfony\Component\Config\Definition\ConfigurationInterface; |
| 511 | + |
| 512 | +class Configuration implements ConfigurationInterface |
| 513 | +{ |
| 514 | +public function getConfigTreeBuilder() |
| 515 | +{ |
| 516 | +$treeBuilder = new TreeBuilder(); |
| 517 | +$rootNode = $treeBuilder->root('acme_hello'); |
| 518 | + |
| 519 | +$rootNode |
| 520 | +->children() |
| 521 | +->scalarNode('my_type') |
| 522 | +->defaultValue('bar') |
| 523 | +->setInfo('what my_type configures') |
| 524 | +->setExample('example setting') |
| 525 | +->end() |
| 526 | +->end() |
| 527 | +; |
| 528 | + |
| 529 | +return $treeBuilder; |
| 530 | +} |
| 531 | + |
| 532 | +This text appears as yaml comments in the output of the ``config:dump-reference`` |
| 533 | +command. |
| 534 | + |
487 | 535 | .. index::
|
488 | 536 | pair: Convention; Configuration
|
489 | 537 |
|
|
0 commit comments