@@ -221,8 +221,9 @@ You can change the inner service name if you want to:
221
221
222
222
Deprecating Services
223
223
--------------------
224
+
224
225
.. versionadded :: 2.8
225
- The ``deprecated `` setting was introduced in Symfony 2.8
226
+ The ``deprecated `` setting was introduced in Symfony 2.8.
226
227
227
228
Once you have decided to deprecate the use of a service (because it is outdated
228
229
or you decided not to use and maintain it anymore), you can deprecate its
@@ -232,21 +233,33 @@ definition:
232
233
233
234
.. code-block :: yaml
234
235
235
- bar :
236
- class : stdClass
237
- deprecated : The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.
236
+ acme.my_service :
237
+ class : ...
238
+ deprecated : The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.
238
239
239
240
.. code-block :: xml
240
241
241
- <service id =" bar" class =" stdClass" >
242
- <deprecated >The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.</deprecated >
243
- </service >
242
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
243
+ <container xmlns =" http://symfony.com/schema/dic/services"
244
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-Instance"
245
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
246
+
247
+ <services >
248
+ <service id =" acme.my_service" class =" ..." >
249
+ <deprecated >The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.</deprecated >
250
+ </service >
251
+ </services >
252
+ </container >
244
253
245
254
.. code-block :: php
246
255
247
256
$container
248
- ->register('bar', 'stdClass')
249
- ->setDeprecated(true, 'The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.');
257
+ ->register('acme.my_service', '...')
258
+ ->setDeprecated(
259
+ true,
260
+ 'The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.'
261
+ )
262
+ ;
250
263
251
264
Now, every time a service is created using this deprecated definition, a
252
265
deprecation warning will be triggered, advising you to stop or to change your
@@ -258,23 +271,22 @@ occurrence of the ``%service_id%`` placeholder in your template.
258
271
259
272
.. note ::
260
273
261
- The deprecation message is optional. If not set, Symfony will show a default
262
- message ``The "%service_id%" service is deprecated. You should stop using it,
263
- as it will soon be removed. ``.
274
+ The deprecation message is optional. If not set, Symfony will show a default
275
+ message ``The "%service_id%" service is deprecated. You should stop using it,
276
+ as it will soon be removed. ``.
264
277
265
278
.. tip ::
266
279
267
- It is strongly recommended that you fill the message template, to avoid a
268
- message that could be too generic such as the default one. A good message
269
- informs when this service was deprecated, and until when it will be
270
- maintained (look at the examples above).
280
+ It is strongly recommended that you fill the message template, to avoid a
281
+ message that could be too generic such as the default one. A good message
282
+ informs when this service was deprecated, and until when it will be
283
+ maintained (look at the examples above).
271
284
272
285
For service decorators (see above), if the definition does not modify the
273
286
deprecated status, it will inherit the status from the definition that is
274
287
decorated.
275
288
276
289
.. caution ::
277
290
278
- The ability to "un-deprecate" a service is possible only when declaring the
279
- definition in PHP.
280
-
291
+ The ability to "un-deprecate" a service is possible only when declaring the
292
+ definition in PHP.
0 commit comments