Comments (7)
It's already optional!
If you pass a variable as second argument of execute method of "CommanderTrait", "mapInputToCommand" won't execute.
from commander.
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?
from commander.
"mapInputToCommand" could not be optional because trait is responsible for creating a command object and than pass it to CommandBus.
If you pass null as second argument, "execute" will make a Command object from Input::all(), otherwise it will make Command object from input array.
from commander.
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.
from commander.
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
from commander.
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.
from commander.
You could do this in the execute method. It would allow an existing command object to pass through and not be reflected.
if( ! is_object($command)) {
$command = $this->mapInputToCommand($command, $input);
}
from commander.
Related Issues (20)
- Validation Decorator HOT 3
- Triggering executeDecorators before validateCommand (in ValidationCommandBus) HOT 1
- Laravel 5 HOT 2
- Method injection CommandHandler HOT 5
- Include a demo basic example project in repo HOT 1
- FIX mapInputToCommand accept $input null
- Testing CommandHandlers with PHPSpec?
- PHPSpec a CommandHandler with DispatchableTrait HOT 1
- CommanderTrait method getCommandBus detected as Controller action HOT 1
- Returning created entity HOT 4
- Validation is being fired twice when using ValidationCommandBus
- Could the package allow for custom Mustache templates to be used when generating commands?
- Decorators of the parent command will be executed on the child command HOT 1
- Warning: Ambiguous class resolution HOT 1
- Specify properties types
- Could this be used in laravel 5 HOT 3
- Using CommanderTrait with Console commands
- Javascript Error on Lead deal analysis HOT 1
- Is this project maintained and usable in production? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commander.