Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Messenger] Allow to override only a few of the abstract middleware definition#29034
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Messenger] Allow to override only a few of the abstract middleware definition#29034
Uh oh!
There was an error while loading.Please reload this page.
Conversation
c9b4d87 toc9ab7baComparenicolas-grekas commentedOct 30, 2018
I think there is a better way, seehttps://github.com/symfony/symfony/pull/29010/files#r229492831 |
ogizanagi left a comment
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.
Good catch. Just really minor comments.
| $container =$this->getContainerBuilder($fooBusId ='messenger.bus.foo'); | ||
| $container->register('middleware_with_factory', UselessMiddleware::class)->addArgument('some_default')->setAbstract(true); | ||
| $container->register('middleware_with_factory_using_default', UselessMiddleware::class)->addArgument('some_default')->setAbstract(true); | ||
| $container->register('middleware_with_factory_using_a_lot_of_defaults', UselessMiddleware::class)->setArguments(array('one','two','three'))->setAbstract(true); |
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.
middleware_with_factory_replacing_defaults_by_index ? 😅 ("Using a lot of defaults" doesn't really convey the intent here)
| $this->assertEquals( | ||
| array('one','2','three','four'), | ||
| $container->getDefinition($factoryWithALotOfDefaultsChildMiddlewareId)->getArguments(), | ||
| 'parent arguments are not overwritten' |
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.
parent arguments are overwritten by index, and next ones appended
nicolas-grekas commentedOct 30, 2018
@ogizanagi see my comment linked above. I don't think we should follow this path. |
ogizanagi commentedOct 30, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas : Continuing the discussion here, as it's seems more scoped here.
The current logic typically allows this:https://symfony.com/doc/current/messenger.html#using-middleware-factories # config/packages/messenger.yamlframework:messenger:buses:command_bus:middleware: -doctrine_transaction_middleware:['index_0' => 'custom'] to change the entity manager name. The idea of such factories was to expose simple config for middlewares. Not leaking Symfony's DIC specificities into it. |
ogizanagi commentedOct 31, 2018
But actually, I'm not fan of this PR allowing to replace any argument by index through the config, just for fixing this issue. function foo($bar ='foo',$baz =3,$qux =null); either you're satisfied with defaults and use So about this issue, I'd suggest a more pragmatic approach:#29038 |
nicolas-grekas commentedOct 31, 2018
👎 let's kill these workarounds on top of hacks. We need to play by the rules of the definition inheritance, not against. |
nicolas-grekas commentedOct 31, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
nope: my suggestion is to make |
nicolas-grekas commentedOct 31, 2018
Already fixed in#29010 (comment) byremoving special edge cases, instead of adding more ;) |
The recent PR about the traceable middleware introduced an issue. This PR fixes it by enabling us to override only some parameters of the parent service.