@@ -196,15 +196,15 @@ a parent for a service.
196
196
calls :
197
197
- [ setMailer, [ @my_mailer ] ]
198
198
- [ setEmailFormatter, [ @my_email_formatter] ]
199
-
199
+
200
200
newsletter_manager :
201
201
class : " %newsletter_manager.class%"
202
202
parent : mail_manager
203
-
203
+
204
204
greeting_card_manager :
205
205
class : " %greeting_card_manager.class%"
206
206
parent : mail_manager
207
-
207
+
208
208
.. code-block :: xml
209
209
210
210
<parameters >
@@ -287,8 +287,8 @@ as a "template" that other services can use.
287
287
288
288
.. note ::
289
289
290
- In order for parent dependencies to resolve, the ``ContainerBuilder `` must
291
- first be compiled. See :doc: `/components/dependency_injection/compilation `
290
+ In order for parent dependencies to resolve, the ``ContainerBuilder `` must
291
+ first be compiled. See :doc: `/components/dependency_injection/compilation `
292
292
for more details.
293
293
294
294
Overriding Parent Dependencies
@@ -322,17 +322,17 @@ to the ``NewsletterManager`` class, the config would look like this:
322
322
calls :
323
323
- [ setMailer, [ @my_mailer ] ]
324
324
- [ setEmailFormatter, [ @my_email_formatter] ]
325
-
325
+
326
326
newsletter_manager :
327
327
class : " %newsletter_manager.class%"
328
328
parent : mail_manager
329
329
calls :
330
330
- [ setMailer, [ @my_alternative_mailer ] ]
331
-
331
+
332
332
greeting_card_manager :
333
333
class : " %greeting_card_manager.class%"
334
334
parent : mail_manager
335
-
335
+
336
336
.. code-block :: xml
337
337
338
338
<parameters >
@@ -453,13 +453,13 @@ If you had the following config:
453
453
abstract : true
454
454
calls :
455
455
- [ setFilter, [ @my_filter ] ]
456
-
456
+
457
457
newsletter_manager :
458
458
class : " %newsletter_manager.class%"
459
459
parent : mail_manager
460
460
calls :
461
461
- [ setFilter, [ @another_filter ] ]
462
-
462
+
463
463
.. code-block :: xml
464
464
465
465
<parameters >
@@ -518,5 +518,13 @@ In this example, the ``setFilter`` of the ``newsletter_manager`` service
518
518
will be called twice, resulting in the ``$filters `` array containing both
519
519
``my_filter `` and ``another_filter `` objects. This is great if you just want
520
520
to add additional filters to the subclasses. If you want to replace the filters
521
- passed to the subclass, removing the parent setting from the config will
521
+ passed to the subclass, removing the parent setting from the config will
522
522
prevent the base class from calling ``setFilter ``.
523
+
524
+ .. tip ::
525
+
526
+ In the examples shown there is a similar relationship between the parent
527
+ and child services and the underlying parent and child classes. This does
528
+ not need to be the case though, you can extract common parts of similar
529
+ service definitions into a parent service without also extracting a parent
530
+ class.
0 commit comments