@@ -161,9 +161,9 @@ all services that were tagged with some specific tag. This is useful in
161
161
compiler passes where you can find these services and use or modify them in
162
162
some specific way.
163
163
164
- For example, if you are using Swift Mailer you might imagine that you want
164
+ For example, if you are using the Symfony Mailer component you might want
165
165
to implement a "transport chain", which is a collection of classes implementing
166
- ``\Swift_Transport ``. Using the chain, you'll want Swift Mailer to try several
166
+ ``\MailerTransport ``. Using the chain, you'll want Mailer to try several
167
167
ways of transporting the message until one succeeds.
168
168
169
169
To begin with, define the ``TransportChain `` class::
@@ -180,7 +180,7 @@ To begin with, define the ``TransportChain`` class::
180
180
$this->transports = [];
181
181
}
182
182
183
- public function addTransport(\Swift_Transport $transport): void
183
+ public function addTransport(\MailerTransport $transport): void
184
184
{
185
185
$this->transports[] = $transport;
186
186
}
@@ -227,7 +227,7 @@ Then, define the chain as a service:
227
227
Define Services with a Custom Tag
228
228
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
229
229
230
- Now you might want several of the ``\Swift_Transport `` classes to be instantiated
230
+ Now you might want several of the ``\MailerTransport `` classes to be instantiated
231
231
and added to the chain automatically using the ``addTransport() `` method.
232
232
For example, you may add the following transports as services:
233
233
@@ -237,11 +237,11 @@ For example, you may add the following transports as services:
237
237
238
238
# config/services.yaml
239
239
services :
240
- Swift_SmtpTransport :
240
+ MailerSmtpTransport :
241
241
arguments : ['%mailer_host%']
242
242
tags : ['app.mail_transport']
243
243
244
- Swift_SendmailTransport :
244
+ MailerSendmailTransport :
245
245
tags : ['app.mail_transport']
246
246
247
247
.. code-block :: xml
@@ -254,13 +254,13 @@ For example, you may add the following transports as services:
254
254
https://symfony.com/schema/dic/services/services-1.0.xsd" >
255
255
256
256
<services >
257
- <service id =" Swift_SmtpTransport " >
257
+ <service id =" MailerSmtpTransport " >
258
258
<argument >%mailer_host%</argument >
259
259
260
260
<tag name =" app.mail_transport" />
261
261
</service >
262
262
263
- <service id =" Swift_SendmailTransport " >
263
+ <service id =" MailerSendmailTransport " >
264
264
<tag name =" app.mail_transport" />
265
265
</service >
266
266
</services >
@@ -274,13 +274,13 @@ For example, you may add the following transports as services:
274
274
return function(ContainerConfigurator $configurator) {
275
275
$services = $configurator->services();
276
276
277
- $services->set(\Swift_SmtpTransport ::class)
277
+ $services->set(\MailerSmtpTransport ::class)
278
278
// the param() method was introduced in Symfony 5.2.
279
279
->args([param('mailer_host')])
280
280
->tag('app.mail_transport')
281
281
;
282
282
283
- $services->set(\Swift_SendmailTransport ::class)
283
+ $services->set(\MailerSendmailTransport ::class)
284
284
->tag('app.mail_transport')
285
285
;
286
286
};
@@ -375,12 +375,12 @@ To begin with, change the ``TransportChain`` class::
375
375
$this->transports = [];
376
376
}
377
377
378
- public function addTransport(\Swift_Transport $transport, $alias): void
378
+ public function addTransport(\MailerTransport $transport, $alias): void
379
379
{
380
380
$this->transports[$alias] = $transport;
381
381
}
382
382
383
- public function getTransport($alias): ?\Swift_Transport
383
+ public function getTransport($alias): ?\MailerTransport
384
384
{
385
385
if (array_key_exists($alias, $this->transports)) {
386
386
return $this->transports[$alias];
@@ -390,7 +390,7 @@ To begin with, change the ``TransportChain`` class::
390
390
}
391
391
}
392
392
393
- As you can see, when ``addTransport() `` is called, it takes not only a ``Swift_Transport ``
393
+ As you can see, when ``addTransport() `` is called, it takes not only a ``MailerTransport ``
394
394
object, but also a string alias for that transport. So, how can you allow
395
395
each tagged transport service to also supply an alias?
396
396
@@ -402,12 +402,12 @@ To answer this, change the service declaration:
402
402
403
403
# config/services.yaml
404
404
services :
405
- Swift_SmtpTransport :
405
+ MailerSmtpTransport :
406
406
arguments : ['%mailer_host%']
407
407
tags :
408
408
- { name: 'app.mail_transport', alias: 'smtp' }
409
409
410
- Swift_SendmailTransport :
410
+ MailerSendmailTransport :
411
411
tags :
412
412
- { name: 'app.mail_transport', alias: 'sendmail' }
413
413
@@ -421,13 +421,13 @@ To answer this, change the service declaration:
421
421
https://symfony.com/schema/dic/services/services-1.0.xsd" >
422
422
423
423
<services >
424
- <service id =" Swift_SmtpTransport " >
424
+ <service id =" MailerSmtpTransport " >
425
425
<argument >%mailer_host%</argument >
426
426
427
427
<tag name =" app.mail_transport" alias =" smtp" />
428
428
</service >
429
429
430
- <service id =" Swift_SendmailTransport " >
430
+ <service id =" MailerSendmailTransport " >
431
431
<tag name =" app.mail_transport" alias =" sendmail" />
432
432
</service >
433
433
</services >
@@ -441,13 +441,13 @@ To answer this, change the service declaration:
441
441
return function(ContainerConfigurator $configurator) {
442
442
$services = $configurator->services();
443
443
444
- $services->set(\Swift_SmtpTransport ::class)
444
+ $services->set(\MailerSmtpTransport ::class)
445
445
// the param() method was introduced in Symfony 5.2.
446
446
->args([param('mailer_host')])
447
447
->tag('app.mail_transport', ['alias' => 'smtp'])
448
448
;
449
449
450
- $services->set(\Swift_SendmailTransport ::class)
450
+ $services->set(\MailerSendmailTransport ::class)
451
451
->tag('app.mail_transport', ['alias' => 'sendmail'])
452
452
;
453
453
};
@@ -463,13 +463,13 @@ To answer this, change the service declaration:
463
463
# config/services.yaml
464
464
services :
465
465
# Compact syntax
466
- Swift_SendmailTransport :
467
- class : \Swift_SendmailTransport
466
+ MailerSendmailTransport :
467
+ class : \MailerSendmailTransport
468
468
tags : ['app.mail_transport']
469
469
470
470
# Verbose syntax
471
- Swift_SendmailTransport :
472
- class : \Swift_SendmailTransport
471
+ MailerSendmailTransport :
472
+ class : \MailerSendmailTransport
473
473
tags :
474
474
- { name: 'app.mail_transport' }
475
475
0 commit comments