Skip to content

Commit e584092

Browse files
committed
minor #17533 [DependencyInjection] [Service container] Remove example with deprecated Swift Mailer (vinceAmstoutz)
This PR was submitted for the 6.2 branch but it was merged into the 5.4 branch instead. Discussion ---------- [DependencyInjection] [Service container] Remove example with deprecated Swift Mailer Solves #17433 Commits ------- 368ed32 From SwiftMailer to Mailer
2 parents 8f0445b + 368ed32 commit e584092

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

service_container/tags.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ all services that were tagged with some specific tag. This is useful in
161161
compiler passes where you can find these services and use or modify them in
162162
some specific way.
163163

164-
For example, if you are using Swift Mailer you might imagine that you want
164+
For example, if you are using the Symfony component Mailer you might imagine that you want
165165
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
167167
ways of transporting the message until one succeeds.
168168

169169
To begin with, define the ``TransportChain`` class::
@@ -180,7 +180,7 @@ To begin with, define the ``TransportChain`` class::
180180
$this->transports = [];
181181
}
182182

183-
public function addTransport(\Swift_Transport $transport): void
183+
public function addTransport(\MailerTransport $transport): void
184184
{
185185
$this->transports[] = $transport;
186186
}
@@ -227,7 +227,7 @@ Then, define the chain as a service:
227227
Define Services with a Custom Tag
228228
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
229229

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
231231
and added to the chain automatically using the ``addTransport()`` method.
232232
For example, you may add the following transports as services:
233233

@@ -237,11 +237,11 @@ For example, you may add the following transports as services:
237237
238238
# config/services.yaml
239239
services:
240-
Swift_SmtpTransport:
240+
MailerSmtpTransport:
241241
arguments: ['%mailer_host%']
242242
tags: ['app.mail_transport']
243243
244-
Swift_SendmailTransport:
244+
MailerSendmailTransport:
245245
tags: ['app.mail_transport']
246246
247247
.. code-block:: xml
@@ -254,13 +254,13 @@ For example, you may add the following transports as services:
254254
https://symfony.com/schema/dic/services/services-1.0.xsd">
255255
256256
<services>
257-
<service id="Swift_SmtpTransport">
257+
<service id="MailerSmtpTransport">
258258
<argument>%mailer_host%</argument>
259259
260260
<tag name="app.mail_transport"/>
261261
</service>
262262
263-
<service id="Swift_SendmailTransport">
263+
<service id="MailerSendmailTransport">
264264
<tag name="app.mail_transport"/>
265265
</service>
266266
</services>
@@ -274,13 +274,13 @@ For example, you may add the following transports as services:
274274
return function(ContainerConfigurator $configurator) {
275275
$services = $configurator->services();
276276
277-
$services->set(\Swift_SmtpTransport::class)
277+
$services->set(\MailerSmtpTransport::class)
278278
// the param() method was introduced in Symfony 5.2.
279279
->args([param('mailer_host')])
280280
->tag('app.mail_transport')
281281
;
282282
283-
$services->set(\Swift_SendmailTransport::class)
283+
$services->set(\MailerSendmailTransport::class)
284284
->tag('app.mail_transport')
285285
;
286286
};
@@ -375,12 +375,12 @@ To begin with, change the ``TransportChain`` class::
375375
$this->transports = [];
376376
}
377377

378-
public function addTransport(\Swift_Transport $transport, $alias): void
378+
public function addTransport(\MailerTransport $transport, $alias): void
379379
{
380380
$this->transports[$alias] = $transport;
381381
}
382382

383-
public function getTransport($alias): ?\Swift_Transport
383+
public function getTransport($alias): ?\MailerTransport
384384
{
385385
if (array_key_exists($alias, $this->transports)) {
386386
return $this->transports[$alias];
@@ -390,7 +390,7 @@ To begin with, change the ``TransportChain`` class::
390390
}
391391
}
392392

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``
394394
object, but also a string alias for that transport. So, how can you allow
395395
each tagged transport service to also supply an alias?
396396

@@ -402,12 +402,12 @@ To answer this, change the service declaration:
402402
403403
# config/services.yaml
404404
services:
405-
Swift_SmtpTransport:
405+
MailerSmtpTransport:
406406
arguments: ['%mailer_host%']
407407
tags:
408408
- { name: 'app.mail_transport', alias: 'smtp' }
409409
410-
Swift_SendmailTransport:
410+
MailerSendmailTransport:
411411
tags:
412412
- { name: 'app.mail_transport', alias: 'sendmail' }
413413
@@ -421,13 +421,13 @@ To answer this, change the service declaration:
421421
https://symfony.com/schema/dic/services/services-1.0.xsd">
422422
423423
<services>
424-
<service id="Swift_SmtpTransport">
424+
<service id="MailerSmtpTransport">
425425
<argument>%mailer_host%</argument>
426426
427427
<tag name="app.mail_transport" alias="smtp"/>
428428
</service>
429429
430-
<service id="Swift_SendmailTransport">
430+
<service id="MailerSendmailTransport">
431431
<tag name="app.mail_transport" alias="sendmail"/>
432432
</service>
433433
</services>
@@ -441,13 +441,13 @@ To answer this, change the service declaration:
441441
return function(ContainerConfigurator $configurator) {
442442
$services = $configurator->services();
443443
444-
$services->set(\Swift_SmtpTransport::class)
444+
$services->set(\MailerSmtpTransport::class)
445445
// the param() method was introduced in Symfony 5.2.
446446
->args([param('mailer_host')])
447447
->tag('app.mail_transport', ['alias' => 'smtp'])
448448
;
449449
450-
$services->set(\Swift_SendmailTransport::class)
450+
$services->set(\MailerSendmailTransport::class)
451451
->tag('app.mail_transport', ['alias' => 'sendmail'])
452452
;
453453
};
@@ -463,13 +463,13 @@ To answer this, change the service declaration:
463463
# config/services.yaml
464464
services:
465465
# Compact syntax
466-
Swift_SendmailTransport:
467-
class: \Swift_SendmailTransport
466+
MailerSendmailTransport:
467+
class: \MailerSendmailTransport
468468
tags: ['app.mail_transport']
469469
470470
# Verbose syntax
471-
Swift_SendmailTransport:
472-
class: \Swift_SendmailTransport
471+
MailerSendmailTransport:
472+
class: \MailerSendmailTransport
473473
tags:
474474
- { name: 'app.mail_transport' }
475475

0 commit comments

Comments
 (0)