8000 [DependencyInjection] Enable deprecating parameters by alexandre-daubois · Pull Request #17741 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] Enable deprecating parameters #17741

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

Closed
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
17 changes: 17 additions & 0 deletions service_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,23 @@ accessor methods for parameters::
To learn more about compiling the container see
:doc:`/components/dependency_injection/compilation`.

It is also possible to deprecate a container parameter. This is particularly useful
if you're writing your own package and want to warn developers to not use a parameter anymore
because it will be removed in one of the next version of your package.
Deprecating a container parameter can be done as follow::

$container->deprecateParameter(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not obvious to me at this point that $container is an instance of ContainerBuilder.

'vendor.database_user',
'vendor-name/package-name',
'1.3',
// optionally you can set a custom deprecation message
'"vendor.database_user" is deprecated, you should configure database credentials with the "vendor.database_dsn" parameter instead.'
);

.. versionadded:: 6.3

The ``ContainerBuilder::deprecateParameter`` method was introduced in Symfony 6.3.

.. _services-wire-specific-service:

Choose a Specific Service
Expand Down
0