-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Messenger] Add a middleware that wraps all handlers in one Doctrine transaction. #26647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e62a0c9
78f021d
50f2cb8
11a3aab
373a2d4
4f54988
1eb6f4d
8b87f2b
a32e6b8
0261a51
f362f50
a629620
05ac7cf
0e0ab07
af65748
701c665
b336d04
7d84394
09e5daf
dcb07ca
1603708
399f7c5
5a6b8de
68131f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -966,6 +966,15 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode) | |
->arrayNode('messenger') | ||
->info('Messenger configuration') | ||
->{!class_exists(FullStack::class) && class_exists(MessageBusInterface::class) ? 'canBeDisabled' : 'canBeEnabled'}() | ||
->beforeNormalization() | ||
->ifTrue(function($config) { | ||
return 8000 empty($config['middlewares']); | ||
}) | ||
->then(function($config) { | ||
$config['middlewares'] = array(); | ||
return $config; | ||
}) | ||
->end() | ||
->children() | ||
->arrayNode('routing') | ||
->useAttributeAsKey('message_class') | ||
|
@@ -998,10 +1007,13 @@ function ($a) { | |
->end() | ||
->end( 8000 ) | ||
->end() | ||
->arrayNode('doctrine_transaction') | ||
->canBeEnabled() | ||
->arrayNode('middlewares') | ||
->children() | ||
->scalarNode('entity_manager_name')->info('The name of the entity manager to use')->defaultNull()->end() | ||
->arrayNode('doctrine_transaction') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be configured via Framework, but via DoctrineBundle. We don't have any other Doctrine config here AFAIR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fabpot are you happy about the middleware being in the bridge, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #26684 is in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also think this makes sense as is. Moving it to doctrine bundle would mean configuring messenger middlewares in two different places, I can't think of a good final result. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @chalasr , it's only a feature flag. It does no harm having this in the fwb whereas having to configure middlewares in 2 different config keys is really bad, DX wise. WDYT? |
||
->canBeEnabled() | ||
->children() | ||
->scalarNode('entity_manager_name')->info('The name of the entity manager to use')->defaultNull()->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
framework: | ||
messenger: | ||
doctrine_transaction: | ||
entity_manager_name: 'foobar' | ||
middlewares: | ||
doctrine_transaction: | ||
entity_manager_name: 'foobar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the proper way of making sure that there always is a config key named "middlewares"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is not. We should of course use
->addDefaultsIfNotSet()