@@ -184,14 +184,12 @@ a parent for a service.
184
184
# ...
185
185
newsletter_manager.class : NewsletterManager
186
186
greeting_card_manager.class : GreetingCardManager
187
- mail_manager.class : MailManager
188
187
services :
189
188
my_mailer :
190
189
# ...
191
190
my_email_formatter :
192
191
# ...
193
192
mail_manager :
194
- class : " %mail_manager.class%"
195
193
abstract : true
196
194
calls :
197
195
- [ setMailer, [ @my_mailer ] ]
@@ -211,7 +209,6 @@ a parent for a service.
211
209
<!-- ... -->
212
210
<parameter key =" newsletter_manager.class" >NewsletterManager</parameter >
213
211
<parameter key =" greeting_card_manager.class" >GreetingCardManager</parameter >
214
- <parameter key =" mail_manager.class" >MailManager</parameter >
215
212
</parameters >
216
213
217
214
<services >
@@ -221,7 +218,7 @@ a parent for a service.
221
218
<service id =" my_email_formatter" ...>
222
219
<!-- ... -->
223
220
</service >
224
- <service id =" mail_manager" class = " %mail_manager.class% " abstract =" true" >
221
+ <service id =" mail_manager" abstract =" true" >
225
222
<call method =" setMailer" >
226
223
<argument type =" service" id =" my_mailer" />
227
224
</call >
@@ -242,12 +239,10 @@ a parent for a service.
242
239
// ...
243
240
$container->setParameter('newsletter_manager.class', 'NewsletterManager');
244
241
$container->setParameter('greeting_card_manager.class', 'GreetingCardManager');
245
- $container->setParameter('mail_manager.class', 'MailManager');
246
242
247
243
$container->setDefinition('my_mailer', ...);
248
244
$container->setDefinition('my_email_formatter', ...);
249
245
$container->setDefinition('mail_manager', new Definition(
250
- '%mail_manager.class%'
251
246
))->setAbstract(
252
247
true
253
248
)->addMethodCall('setMailer', array(
@@ -279,11 +274,10 @@ when the child services are instantiated.
279
274
defined on the ``mail_manager `` service will not be executed when the
280
275
child services are instantiated.
281
276
282
- The parent class is abstract as it should not be directly instantiated. Setting
283
- it to abstract in the config file as has been done above will mean that it
284
- can only be used as a parent service and cannot be used directly as a service
285
- to inject and will be removed at compile time. In other words, it exists merely
286
- as a "template" that other services can use.
277
+ The parent service is abstract as it should not be directly retrieved from the
278
+ container or passed into another service. It exists merely as a "template" that
279
+ other services can use. This is why it can have no ``class `` configured which
280
+ would cause an exception to be raised for a non-abstract service.
287
281
288
282
.. note ::
289
283
@@ -308,7 +302,6 @@ to the ``NewsletterManager`` class, the config would look like this:
308
302
# ...
309
303
newsletter_manager.class : NewsletterManager
310
304
greeting_card_manager.class : GreetingCardManager
311
- mail_manager.class : MailManager
312
305
services :
313
306
my_mailer :
314
307
# ...
@@ -317,7 +310,6 @@ to the ``NewsletterManager`` class, the config would look like this:
317
310
my_email_formatter :
318
311
# ...
319
312
mail_manager :
320
- class : " %mail_manager.class%"
321
313
abstract : true
322
314
calls :
323
315
- [ setMailer, [ @my_mailer ] ]
@@ -339,7 +331,6 @@ to the ``NewsletterManager`` class, the config would look like this:
339
331
<!-- ... -->
340
332
<parameter key =" newsletter_manager.class" >NewsletterManager</parameter >
341
333
<parameter key =" greeting_card_manager.class" >GreetingCardManager</parameter >
342
- <parameter key =" mail_manager.class" >MailManager</parameter >
343
334
</parameters >
344
335
345
336
<services >
@@ -352,7 +343,7 @@ to the ``NewsletterManager`` class, the config would look like this:
352
343
<service id =" my_email_formatter" ...>
353
344
<!-- ... -->
354
345
</service >
355
- <service id =" mail_manager" class = " %mail_manager.class% " abstract =" true" >
346
+ <service id =" mail_manager" abstract =" true" >
356
347
<call method =" setMailer" >
357
348
<argument type =" service" id =" my_mailer" />
358
349
</call >
@@ -377,13 +368,11 @@ to the ``NewsletterManager`` class, the config would look like this:
377
368
// ...
378
369
$container->setParameter('newsletter_manager.class', 'NewsletterManager');
379
370
$container->setParameter('greeting_card_manager.class', 'GreetingCardManager');
380
- $container->setParameter('mail_manager.class', 'MailManager');
381
371
382
372
$container->setDefinition('my_mailer', ...);
383
373
$container->setDefinition('my_alternative_mailer', ...);
384
374
$container->setDefinition('my_email_formatter', ...);
385
375
$container->setDefinition('mail_manager', new Definition(
386
- '%mail_manager.class%'
387
376
))->setAbstract(
388
377
true
389
378
)->addMethodCall('setMailer', array(
@@ -442,14 +431,12 @@ If you had the following config:
442
431
parameters :
443
432
# ...
444
433
newsletter_manager.class : NewsletterManager
445
- mail_manager.class : MailManager
446
434
services :
447
435
my_filter :
448
436
# ...
449
437
another_filter :
450
438
# ...
451
439
mail_manager :
452
- class : " %mail_manager.class%"
453
440
abstract : true
454
441
calls :
455
442
- [ setFilter, [ @my_filter ] ]
@@ -465,7 +452,6 @@ If you had the following config:
465
452
<parameters >
466
453
<!-- ... -->
467
454
<parameter key =" newsletter_manager.class" >NewsletterManager</parameter >
468
- <parameter key =" mail_manager.class" >MailManager</parameter >
469
455
</parameters >
470
456
471
457
<services >
@@ -475,7 +461,7 @@ If you had the following config:
475
461
<service id =" another_filter" ...>
476
462
<!-- ... -->
477
463
</service >
478
- <service id =" mail_manager" class = " %mail_manager.class% " abstract =" true" >
464
+ <service id =" mail_manager" abstract =" true" >
479
465
<call method =" setFilter" >
480
466
<argument type =" service" id =" my_filter" />
481
467
</call >
@@ -500,7 +486,6 @@ If you had the following config:
500
486
$container->setDefinition('my_filter', ...);
501
487
$container->setDefinition('another_filter', ...);
502
488
$container->setDefinition('mail_manager', new Definition(
503
- '%mail_manager.class%'
504
489
))->setAbstract(
505
490
true
506
491
)->addMethodCall('setFilter', array(
0 commit comments