Skip to content

[Options Resolver] Using placeholder to use dynamic parameter #19114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion components/options_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,14 @@ method::
->setDeprecated('hostname', 'acme/package', '1.2')

// you can also pass a custom deprecation message (%name% placeholder is available)
// %name% placeholder will be replaced by the deprecated option.
// This outputs the following deprecation message:
// Since acme/package 1.2: The option "hostname" is deprecated, use "host" instead.
->setDeprecated(
'hostname',
'acme/package',
'1.2',
'The option "hostname" is deprecated, use "host" instead.'
'The option "%name%" is deprecated, use "host" instead.'
)
;

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

.. note::

All deprecation messages are displayed in the profiler logs into Deprecations tab.

Instead of passing the message, you may also pass a closure which returns
a string (the deprecation message) or an empty string to ignore the deprecation.
This closure is useful to only deprecate some of the allowed types or values of
Expand Down