10000 minor #19114 [Options Resolver] Using placeholder to use dynamic para… · symfony/symfony-docs@f3f98b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3f98b0

Browse files
committed
minor #19114 [Options Resolver] Using placeholder to use dynamic parameter (devojifr)
This PR was merged into the 5.4 branch. Discussion ---------- [Options Resolver] Using placeholder to use dynamic parameter The comment specifies the %name% placeholder possibility. We can use it to give a better understanding of the custom deprecation message. I also add a reminder about where deprecations are displayed. Commits ------- fd72006 [Options Resolver] Using placeholder to use dynamic parameter
2 parents b03da98 + fd72006 commit f3f98b0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/options_resolver.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,11 +801,14 @@ method::
801801
->setDeprecated('hostname', 'acme/package', '1.2')
802802

803803
// you can also pass a custom deprecation message (%name% placeholder is available)
804+
// %name% placeholder will be replaced by the deprecated option.
805+
// This outputs the following deprecation message:
806+
// Since acme/package 1.2: The option "hostname" is deprecated, use "host" instead.
804807
->setDeprecated(
805808
'hostname',
806809
'acme/package',
807810
'1.2',
808-
'The option "hostname" is deprecated, use "host" instead.'
811+
'The option "%name%" is deprecated, use "host" instead.'
809812
)
810813
;
811814

@@ -822,6 +825,10 @@ method::
822825
:method:`Symfony\\Component\\OptionsResolver\\Options::offsetGet` method
823826
to not trigger the deprecation warning.
824827

828+
.. note::
829+
830+
All deprecation messages are displayed in the profiler logs into Deprecations tab.
831+
825832
Instead of passing the message, you may also pass a closure which returns
826833
a string (the deprecation message) or an empty string to ignore the deprecation.
827834
This closure is useful to only deprecate some of the allowed types or values of

0 commit comments

Comments
 (0)
0