-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Messenger] Document the ActivationMiddlewareDecorator #10035
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
Comments
I think would be nice use more real-life example. For example we are using Solution: decorate |
@Koc : This seems to be very specific to me (but most of the use-cases of this feature are). I thought the env condition was one of the most straightforward ones to showcase and understand for readers. But I'm not against other suggestions :) |
Thank you for this issue. |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
Relates to symfony/symfony#27320
This middleware is used to enable/disable a middleware based on an arbitrary condition. Main use-case is for maintaining a unique list of middleware across environments, but disabling/enabling some in test env for instance (but there are many others). It accepts either a simple boolean or a callable returning a boolean.
Usage when using the component standalone should be straightforward enough, but not as obvious when using within the framework.
When used with the framework, it leverages Symfony DI capabilities (using service decoration). It can uses a simple parameter value, the result of an expression, or even a callable injected in its constructor (by extending the decorator or by using DI):
using an invokable service:
using a method of a service as a closure (dynamically executed, as previously):
Note: a more concise syntax can be used leveraging anonymous services:
[...]
The text was updated successfully, but these errors were encountered: