diff --git a/service_container/alias_private.rst b/service_container/alias_private.rst index 756ab691b68..eda3658c778 100644 --- a/service_container/alias_private.rst +++ b/service_container/alias_private.rst @@ -146,6 +146,69 @@ This means that when using the container directly, you can access the # ... app.mailer: '@App\Mail\PhpMailer' +Deprecating Service Aliases +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you decide to deprecate the use of a service alias (because it is outdated +or you decided not to maintain it anymore), you can deprecate its definition: + +.. configuration-block:: + + .. code-block:: yaml + + app.mailer: + alias: '@AppBundle\Mail\PhpMailer' + + # this will display a generic deprecation message... + deprecated: true + + # ...but you can also define a custom deprecation message + deprecated: 'The "%alias_id%" alias is deprecated. Don\'t use it anymore.' + + .. code-block:: xml + + + + + + + + + + + The "%alias_id%" service alias is deprecated. Don't use it anymore. + + + + + .. code-block:: php + + $container + ->setAlias('app.mailer', 'App\Mail\PhpMailer') + + // this will display a generic deprecation message... + ->setDeprecated(true) + + // ...but you can also define a custom deprecation message + ->setDeprecated( + true, + 'The "%alias_id%" service alias is deprecated. Don\'t use it anymore.' + ) + ; + +Now, every time this service alias is used, a deprecation warning is triggered, +advising you to stop or to change your uses of that alias. + +The message is actually a message template, which replaces occurrences of the +``%alias_id%`` placeholder by the service alias id. You **must** have at least +one occurrence of the ``%alias_id%`` placeholder in your template. + +.. versionadded:: 4.3 + + The ``deprecated`` option for service aliases was introduced in Symfony 4.3. + Anonymous Services ------------------ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy