From b6693841f2e22ceef1cd6b073b05d3311d4fe79e Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Sat, 14 Jan 2023 16:27:06 +0100 Subject: [PATCH] [DependencyInjection] Enable deprecating parameters --- service_container.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/service_container.rst b/service_container.rst index 5593b02d8a4..be1c9f935fe 100644 --- a/service_container.rst +++ b/service_container.rst @@ -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( + '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