@@ -129,11 +129,13 @@ Then, define the chain as a service:
129
129
130
130
.. code-block :: yaml
131
131
132
+ # config/services.yaml
132
133
services :
133
134
App\Mail\TransportChain : ~
134
135
135
136
.. code-block :: xml
136
137
138
+ <!-- config/services.xml -->
137
139
<?xml version =" 1.0" encoding =" UTF-8" ?>
138
140
<container xmlns =" http://symfony.com/schema/dic/services"
139
141
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
@@ -147,6 +149,7 @@ Then, define the chain as a service:
147
149
148
150
.. code-block :: php
149
151
152
+ // config/services.php
150
153
use App\Mail\TransportChain;
151
154
152
155
$container->autowire(TransportChain::class);
@@ -162,6 +165,7 @@ For example, you may add the following transports as services:
162
165
163
166
.. code-block :: yaml
164
167
168
+ # config/services.yaml
165
169
services :
166
170
Swift_SmtpTransport :
167
171
arguments : ['%mailer_host%']
@@ -172,6 +176,7 @@ For example, you may add the following transports as services:
172
176
173
177
.. code-block :: xml
174
178
179
+ <!-- config/services.xml -->
175
180
<?xml version =" 1.0" encoding =" UTF-8" ?>
176
181
<container xmlns =" http://symfony.com/schema/dic/services"
177
182
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
@@ -193,6 +198,7 @@ For example, you may add the following transports as services:
193
198
194
199
.. code-block :: php
195
200
201
+ // config/services.php
196
202
$container->register(\Swift_SmtpTransport::class)
197
203
->addArgument('%mailer_host%')
198
204
->addTag('app.mail_transport');
@@ -245,18 +251,18 @@ Register the Pass with the Container
245
251
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246
252
247
253
In order to run the compiler pass when the container is compiled, you have to
248
- add the compiler pass to the container in the `` build() `` method of your
249
- bundle ::
254
+ add the compiler pass to the container in a :doc: ` bundle extension < /bundles/extension >`
255
+ or from your kernel ::
250
256
251
- // src/AppBundle.php
252
-
253
- // ...
254
- use Symfony\Component\DependencyInjection\ContainerBuilder;
257
+ // src/Kernel.php
255
258
use App\DependencyInjection\Compiler\MailTransportPass;
259
+ // ...
256
260
257
- class AppBundle extends Bundle
261
+ class Kernel extends Kernel
258
262
{
259
- public function build(ContainerBuilder $container)
263
+ // ...
264
+
265
+ protected function build(ContainerBuilder $container)
260
266
{
261
267
$container->addCompilerPass(new MailTransportPass());
262
268
}
@@ -310,6 +316,7 @@ To answer this, change the service declaration:
310
316
311
317
.. code-block :: yaml
312
318
319
+ # config/services.yaml
313
320
services :
314
321
Swift_SmtpTransport :
315
322
arguments : ['%mailer_host%']
@@ -322,6 +329,7 @@ To answer this, change the service declaration:
322
329
323
330
.. code-block :: xml
324
331
332
+ <!-- config/services.xml -->
325
333
<?xml version =" 1.0" encoding =" UTF-8" ?>
326
334
<container xmlns =" http://symfony.com/schema/dic/services"
327
335
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
@@ -343,6 +351,7 @@ To answer this, change the service declaration:
343
351
344
352
.. code-block :: php
345
353
354
+ // config/services.php
346
355
$container->register(\Swift_SmtpTransport::class)
347
356
->addArgument('%mailer_host%')
348
357
->addTag('app.mail_transport', array('alias' => 'foo'));
@@ -358,8 +367,8 @@ To answer this, change the service declaration:
358
367
359
368
.. code-block :: yaml
360
369
370
+ # config/services.yaml
361
371
services :
362
-
363
372
# Compact syntax
364
373
Swift_SendmailTransport :
365
374
class : \Swift_SendmailTransport
0 commit comments