@@ -276,37 +276,37 @@ you can disable them like this:
276
276
Using Middleware Factories
277
277
~~~~~~~~~~~~~~~~~~~~~~~~~~
278
278
279
- Some third-parties may expose you configurable middleware by using factories.
280
- Such factories are actually relying on the Symfony DI capabilities and consist
281
- of this kind of two services :
279
+ Sometimes middleware are configurable using factories. There are two types of
280
+ factories and they are based on Symfony's :doc: ` dependency injection < /service_container >`
281
+ features :
282
282
283
283
.. code-block :: yaml
284
284
285
285
services :
286
286
287
- # A factory class is registered as a service with required dependencies
288
- # to instantiate a middleware:
287
+ # Type 1: a factory class is registered as a service with the required
288
+ # dependencies to instantiate a middleware
289
289
doctrine.orm.messenger.middleware_factory.transaction :
290
- class : Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory
291
- arguments : ['@doctrine']
290
+ class : Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory
291
+ arguments : ['@doctrine']
292
292
293
- # An abstract definition that will call the factory with default arguments
294
- # or the one provided in the middleware config:
293
+ # Type 2: an abstract definition that will call the factory with default arguments
294
+ # or the one provided in the middleware config
295
295
messenger.middleware.doctrine_transaction_middleware :
296
- class : Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware
297
- factory : ['@doctrine.orm.messenger.middleware_factory.transaction', 'createMiddleware']
298
- abstract : true
299
- # the default arguments to use when none provided from config.
300
- # i.e:
301
- # middleware:
302
- # - doctrine_transaction_middleware: ~
303
- arguments : ['default']
296
+ class : Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware
297
+ factory : ['@doctrine.orm.messenger.middleware_factory.transaction', 'createMiddleware']
298
+ abstract : true
299
+ # the default arguments to use when none provided from config. Example:
300
+ # middleware:
301
+ # - doctrine_transaction_middleware: ~
302
+ arguments : ['default']
304
303
305
- The "default" value in this example corresponds to the entity manager name to use, as expected by the
306
- ``Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory::createMiddleware `` method as argument.
304
+ The "default" value in this example is the name of the entity manager to use,
305
+ which is the argument expected by the
306
+ ``Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory::createMiddleware `` method.
307
307
308
- Then you can reference and configure the `` messenger.middleware.doctrine_transaction_middleware ``
309
- service as a middleware:
308
+ Then you can reference and configure the
309
+ `` messenger.middleware.doctrine_transaction_middleware `` service as a middleware:
310
310
311
311
.. configuration-block ::
312
312
@@ -368,18 +368,20 @@ service as a middleware:
368
368
369
369
.. note ::
370
370
371
- The shorthand ``doctrine_transaction_middleware `` name can be used by convention,
372
- as the service id is prefixed with the ``messenger.middleware. `` namespace.
371
+ The ``doctrine_transaction_middleware `` shortcut is a convention. The real
372
+ service id is prefixed with the ``messenger.middleware. `` namespace.
373
373
374
374
.. note ::
375
375
376
- Middleware factories only allow scalar and array arguments in config (no service reference).
377
- For most advanced use-cases, register a concrete definition of the middleware yourself and use its id.
376
+ Middleware factories only allow scalar and array arguments in config (no
377
+ references to other services). For most advanced use-cases, register a
378
+ concrete definition of the middleware manually and use its id.
378
379
379
380
.. tip ::
380
381
381
- The ``doctrine_transaction_middleware `` is an existing middleware wired
382
- by the DoctrineBundle if installed and the Messenger component enabled.
382
+ The ``doctrine_transaction_middleware `` is a built-in middleware wired
383
+ automatically when the DoctrineBundle and the Messenger component are
384
+ installed and enabled.
383
385
384
386
Your own Transport
385
387
------------------
0 commit comments