@@ -160,6 +160,12 @@ This means that when using the container directly, you can access the
160160 Deprecating Service Aliases
161161~~~~~~~~~~~~~~~~~~~~~~~~~~~
162162
163+ .. versionadded :: 5.1
164+
165+ The ``package `` and ``version `` options were introduced in Symfony 5.1.
166+ Prior to 5.1, you had to use ``deprecated: true `` or
167+ ``deprecated: 'Custom message' ``.
168+
163169If you decide to deprecate the use of a service alias (because it is outdated
164170or you decided not to maintain it anymore), you can deprecate its definition:
165171
@@ -170,11 +176,17 @@ or you decided not to maintain it anymore), you can deprecate its definition:
170176 app.mailer :
171177 alias : ' @App\Mail\PhpMailer'
172178
173- # this will display a generic deprecation message...
174- deprecated : true
179+ # this outputs the following generic deprecation message:
180+ # Since acme/package 1.2: The "app.mailer" service is deprecated. You should stop using it, as it will be removed in the future
181+ deprecated :
182+ package : ' acme/package'
183+ version : ' 1.2'
175184
176- # ...but you can also define a custom deprecation message
177- deprecated : ' The "%alias_id%" alias is deprecated. Do not use it anymore.'
185+ # you can also define a custom deprecation message (%sevice_id%/%alias_id% placeholder is available)
186+ deprecated :
187+ package : ' acme/package'
188+ version : ' 1.2'
189+ message : ' The "%alias_id%" alias is deprecated. Do not use it anymore.'
178190
179191 .. code-block :: xml
180192
@@ -185,11 +197,14 @@ or you decided not to maintain it anymore), you can deprecate its definition:
185197
186198 <services >
187199 <service id =" app.mailer" alias =" App\Mail\PhpMailer" >
188- <!-- this will display a generic deprecation message... -->
189- <deprecated />
190-
191- <!-- ...but you can also define a custom deprecation message -->
192- <deprecated >The "%alias_id%" service alias is deprecated. Don't use it anymore.</deprecated >
200+ <!-- this outputs the following generic deprecation message:
201+ Since acme/package 1.2: The "app.mailer" service is deprecated. You should stop using it, as it will be removed in the future -->
202+ <deprecated package =" acme/package" version =" 1.2" />
203+
204+ <!-- you can also define a custom deprecation message (%sevice_id%/%alias_id% placeholder is available) -->
205+ <deprecated package =" acme/package" version =" 1.2" >
206+ The "%alias_id%" service alias is deprecated. Don't use it anymore.
207+ </deprecated >
193208 </service >
194209 </services >
195210 </container >
@@ -199,12 +214,14 @@ or you decided not to maintain it anymore), you can deprecate its definition:
199214 $container
200215 ->setAlias('app.mailer', 'App\Mail\PhpMailer')
201216
202- // this will display a generic deprecation message...
203- ->setDeprecated(true)
217+ // this outputs the following generic deprecation message:
218+ // Since acme/package 1.2: The "app.mailer" service is deprecated. You should stop using it, as it will be removed in the future
219+ ->setDeprecated('acme/package', '1.2')
204220
205- // ...but you can also define a custom deprecation message
221+ // you can also define a custom deprecation message (%sevice_id%/%alias_id% placeholder is available)
206222 ->setDeprecated(
207- true,
223+ 'acme/package',
224+ '1.2',
208225 'The "%alias_id%" service alias is deprecated. Don\'t use it anymore.'
209226 )
210227 ;
0 commit comments