Skip to content

Commit 1939371

Browse files
javiereguiluzxabbuh
authored andcommitted
Explained the possibility of defining custom deprecation messages
1 parent d6a8624 commit 1939371

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

components/config/definition.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,24 +424,27 @@ has a certain value:
424424
->end()
425425
;
426426
427-
Deprecated the Option
428-
---------------------
427+
Deprecating the Option
428+
----------------------
429429

430-
You can depreciate an option by using the
430+
You can deprecate options using the
431431
:method:`Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::setDeprecated`
432-
method.
433-
434-
.. code-block:: php
432+
method::
435433

436434
$rootNode
437435
->children()
438436
->integerNode('old_option')
437+
// this outputs the following generic deprecation message:
438+
// The child node "old_option" at path "..." is deprecated.
439439
->setDeprecated()
440+
441+
// you can also pass a custom deprecation message (%node% and %path% placeholders are available):
442+
->setDeprecated('The "%node%" option is deprecated. Use "new_config_option" instead.')
440443
->end()
441444
->end()
442445
;
443446

444-
If you use the Web Debug Toolbar, the deprecation notice will be showed when the
447+
If you use the Web Debug Toolbar, these deprecation notices are shown when the
445448
configuration is rebuilt.
446449

447450
Documenting the Option

0 commit comments

Comments
 (0)