Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d3bdaa

Browse files
committed
Minor reword
1 parent dcc3404 commit 3d3bdaa

File tree

1 file changed

+15
-34
lines changed

1 file changed

+15
-34
lines changed

mailer.rst

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -359,50 +359,31 @@ Other Options
359359
Custom Transport Factories
360360
~~~~~~~~~~~~~~~~~~~~~~~~~~
361361

362-
There is a way to easily create your own custom transport factory in case you need to do something special creating the actual transport.
363-
364-
The new factory needs to implement :class:`Symfony\\Component\\Mailer\\Transport\\TransportFactoryInterface`. To remove some boilerplate you can even extend from :class:`Symfony\\Component\\Mailer\\Transport\\AbstractTransportFactory` which will simplify the new factory::
365-
366-
367-
final class CustomTransportFactory extends AbstractTransportFactory
362+
If you want to support your own custom DSN (``acme://...``), you can create a
363+
custom transport factory. To do so, create a class that implements
364+
:class:`Symfony\\Component\\Mailer\\Transport\\TransportFactoryInterface` or, if
365+
you prefer, extend the :class:`Symfony\\Component\\Mailer\\Transport\\AbstractTransportFactory`
366+
class to save some boilerplate code::
367+
368+
// src/Mailer/AcmeTransportFactory.php
369+
final class AcmeTransportFactory extends AbstractTransportFactory
368370
{
369371
public function create(Dsn $dsn): TransportInterface
370372
{
371-
// create and return the transport
373+
// parse the given DSN, extract data/credentials from it
374+
// and then, create and return the transport
372375
}
373376

374377
protected function getSupportedSchemes(): array
375378
{
376-
return ['custom_schema'];
379+
// this supports DSN starting with `acme://`
380+
return ['acme'];
377381
}
378382
}
379383

380-
Finally, declare the new factory in setting tag the tag `mailer.transport_factory`:
381-
382-
.. configuration-block::
383-
384-
.. code-block:: yaml
385-
386-
# config/services.yaml
387-
mailer.transport_factory.custom:
388-
class: App\CustomTransportFactory
389-
parent: mailer.transport_factory.abstract
390-
tags:
391-
- {name: mailer.transport_factory}
392-
393-
.. code-block:: xml
394-
395-
<!-- config/services.xml -->
396-
<service id="mailer.transport_factory.custom" class="App\CustomTransportFactory" parent="mailer.transport_factory.abstract">
397-
<tag name="mailer.transport_factory"/>
398-
</service>
399-
400-
.. code-block:: php
401-
402-
// config/services.php
403-
$services->set('mailer.transport_factory.custom', App\CustomTransportFactory::class)
404-
->parent('mailer.transport_factory.abstract')
405-
->tag('mailer.transport_factory');
384+
After creating the custom transport class, register it as a service in your
385+
application and :doc:`tag it </service_container/tags>` with the
386+
``mailer.transport_factory`` tag.
406387

407388
Creating & Sending Messages
408389
---------------------------

0 commit comments

Comments
 (0)