Skip to content

Commit c9a4bbf

Browse files
committed
[#5689] Some minor syntax fixes
1 parent 44f8496 commit c9a4bbf

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

components/dependency_injection/advanced.rst

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ You can change the inner service name if you want to:
221221
222222
Deprecating Services
223223
--------------------
224+
224225
.. versionadded:: 2.8
225-
The ``deprecated`` setting was introduced in Symfony 2.8
226+
The ``deprecated`` setting was introduced in Symfony 2.8.
226227

227228
Once you have decided to deprecate the use of a service (because it is outdated
228229
or you decided not to use and maintain it anymore), you can deprecate its
@@ -232,21 +233,33 @@ definition:
232233

233234
.. code-block:: yaml
234235
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.
238239
239240
.. code-block:: xml
240241
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>
244253
245254
.. code-block:: php
246255
247256
$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+
;
250263
251264
Now, every time a service is created using this deprecated definition, a
252265
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.
258271

259272
.. note::
260273

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.``.
264277

265278
.. tip::
266279

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).
271284

272285
For service decorators (see above), if the definition does not modify the
273286
deprecated status, it will inherit the status from the definition that is
274287
decorated.
275288

276289
.. caution::
277290

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

Comments
 (0)