-
Notifications
You must be signed in to change notification settings - Fork 65
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
Make mapInputToCommand optional in CommanderTrait #47
Comments
It's already optional! |
Hi miladir When I checked the source I see execute always calls mapInputToCommand and reflects into your command class no matter what you give as second argument. I'm saying that for times that you don't need to have your class reflected into we could have a simple optional parameter on execute that would optionally abort calling mapInputToCommand. Otherwise, you are always stuck with input::all, or a default value on your command class parameter, or having to pass your own array. Perhaps passing your own array is what Jeff intended? |
"mapInputToCommand" could not be optional because trait is responsible for creating a command object and than pass it to CommandBus. |
Yeah I see that, I was just thinking say you had a command object already made, and then just pass it to execute with a flag to not reflect. In that case you wouldn't have to construct that input array. But no big deal if you don't like my idea. |
You wouldn't even have to have a flag, mapInputToCommand could run depending on if you passed a class or an existing object to execute |
Your idea works too but the idea behind CommandBus design pattern is making code in Controller as close as possible to real world Business language. In real world business a manager will say to his/her employers to do something with the input data. Manager is not responsible to shape data. Employer should shape data before use it and report to Manager that the job is done or fail. |
You could do this in the execute method. It would allow an existing command object to pass through and not be reflected.
|
Hi Jeffrey,
For CommanderTrait I thought it might be handy to make mapInputToCommand in the execute method optional because sometimes you may wish to build up a command object that is not directly tied to a form input. For example, say you want to pass the currently authenticated user's id into the command. This value would not come from a form input, but directly from the controller. What do you think? Am I missing something totally obvious? As always, thanks, you do great work!
The text was updated successfully, but these errors were encountered: